diff --git a/camera/camera_driver.c b/camera/camera_driver.c index d453e17718..c7217fce1a 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -15,10 +15,10 @@ */ #include -#include #include "camera_driver.h" #include "../general.h" +#include "../string_list_special.h" static const camera_driver_t *camera_drivers[] = { #ifdef HAVE_V4L2 @@ -80,39 +80,7 @@ const char *camera_driver_find_ident(int idx) **/ const char* config_get_camera_driver_options(void) { - union string_list_elem_attr attr; - 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; camera_driver_find_handle(i); i++) - { - const char *opt = camera_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; + return string_list_special_new(STRING_LIST_CAMERA_DRIVERS); } void find_camera_driver(void) diff --git a/string_list_special.c b/string_list_special.c index e0913d7d5e..f24ee44a15 100644 --- a/string_list_special.c +++ b/string_list_special.c @@ -22,6 +22,10 @@ #include "menu/menu_driver.h" #endif +#ifdef HAVE_CAMERA +#include "camera/camera_driver.h" +#endif + const char *string_list_special_new(enum string_list_type type) { union string_list_elem_attr attr; @@ -47,6 +51,17 @@ const char *string_list_special_new(enum string_list_type type) string_list_append(s, opt, attr); } break; +#endif + case STRING_LIST_CAMERA_DRIVERS: +#ifdef HAVE_CAMERA + for (i = 0; camera_driver_find_handle(i); i++) + { + const char *opt = camera_driver_find_ident(i); + len += strlen(opt) + 1; + + string_list_append(s, opt, attr); + } + break; #endif case STRING_LIST_NONE: default: diff --git a/string_list_special.h b/string_list_special.h index fba7696955..75d43fdf2c 100644 --- a/string_list_special.h +++ b/string_list_special.h @@ -19,7 +19,8 @@ enum string_list_type { STRING_LIST_NONE = 0, - STRING_LIST_MENU_DRIVERS + STRING_LIST_MENU_DRIVERS, + STRING_LIST_CAMERA_DRIVERS }; const char *string_list_special_new(enum string_list_type type);