More code deduplication
This commit is contained in:
parent
aff1bd03de
commit
0116ea5ba5
|
@ -16,9 +16,8 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <string/string_list.h>
|
|
||||||
|
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
|
#include "../string_list_special.h"
|
||||||
|
|
||||||
static const input_driver_t *input_drivers[] = {
|
static const input_driver_t *input_drivers[] = {
|
||||||
#ifdef __CELLOS_LV2__
|
#ifdef __CELLOS_LV2__
|
||||||
|
@ -109,39 +108,7 @@ const char *input_driver_find_ident(int idx)
|
||||||
**/
|
**/
|
||||||
const char* config_get_input_driver_options(void)
|
const char* config_get_input_driver_options(void)
|
||||||
{
|
{
|
||||||
union string_list_elem_attr attr;
|
return string_list_special_new(STRING_LIST_INPUT_DRIVERS);
|
||||||
unsigned i;
|
|
||||||
char *options = NULL;
|
|
||||||
int options_len = 0;
|
|
||||||
struct string_list *options_l = string_list_new();
|
|
||||||
|
|
||||||
attr.i = 0;
|
|
||||||
|
|
||||||
if (!options_l)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (i = 0; input_driver_find_handle(i); i++)
|
|
||||||
{
|
|
||||||
const char *opt = input_driver_find_ident(i);
|
|
||||||
options_len += strlen(opt) + 1;
|
|
||||||
string_list_append(options_l, opt, attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
options = (char*)calloc(options_len, sizeof(char));
|
|
||||||
|
|
||||||
if (!options)
|
|
||||||
{
|
|
||||||
string_list_free(options_l);
|
|
||||||
options_l = NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
string_list_join_concat(options, options_len, options_l, "|");
|
|
||||||
|
|
||||||
string_list_free(options_l);
|
|
||||||
options_l = NULL;
|
|
||||||
|
|
||||||
return options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_input_driver(void)
|
void find_input_driver(void)
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "camera/camera_driver.h"
|
#include "camera/camera_driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gfx/video_driver.h"
|
||||||
|
#include "input/input_driver.h"
|
||||||
#include "audio/audio_driver.h"
|
#include "audio/audio_driver.h"
|
||||||
|
|
||||||
const char *string_list_special_new(enum string_list_type type)
|
const char *string_list_special_new(enum string_list_type type)
|
||||||
|
@ -83,6 +85,15 @@ const char *string_list_special_new(enum string_list_type type)
|
||||||
string_list_append(s, opt, attr);
|
string_list_append(s, opt, attr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case STRING_LIST_INPUT_DRIVERS:
|
||||||
|
for (i = 0; input_driver_find_handle(i); i++)
|
||||||
|
{
|
||||||
|
const char *opt = input_driver_find_ident(i);
|
||||||
|
len += strlen(opt) + 1;
|
||||||
|
|
||||||
|
string_list_append(s, opt, attr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case STRING_LIST_NONE:
|
case STRING_LIST_NONE:
|
||||||
default:
|
default:
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -22,7 +22,8 @@ enum string_list_type
|
||||||
STRING_LIST_MENU_DRIVERS,
|
STRING_LIST_MENU_DRIVERS,
|
||||||
STRING_LIST_CAMERA_DRIVERS,
|
STRING_LIST_CAMERA_DRIVERS,
|
||||||
STRING_LIST_AUDIO_DRIVERS,
|
STRING_LIST_AUDIO_DRIVERS,
|
||||||
STRING_LIST_VIDEO_DRIVERS
|
STRING_LIST_VIDEO_DRIVERS,
|
||||||
|
STRING_LIST_INPUT_DRIVERS
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *string_list_special_new(enum string_list_type type);
|
const char *string_list_special_new(enum string_list_type type);
|
||||||
|
|
Loading…
Reference in New Issue