mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
(string_list_special.c) Code de-duplication
This commit is contained in:
parent
415176e360
commit
bb10bc06b7
@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <string/string_list.h>
|
|
||||||
|
|
||||||
#include "audio_monitor.h"
|
#include "audio_monitor.h"
|
||||||
#include "audio_driver.h"
|
#include "audio_driver.h"
|
||||||
#include "audio_utils.h"
|
#include "audio_utils.h"
|
||||||
#include "audio_thread_wrapper.h"
|
#include "audio_thread_wrapper.h"
|
||||||
|
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
|
#include "../string_list_special.h"
|
||||||
|
|
||||||
#ifndef AUDIO_BUFFER_FREE_SAMPLES_COUNT
|
#ifndef AUDIO_BUFFER_FREE_SAMPLES_COUNT
|
||||||
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
|
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
|
||||||
@ -223,42 +223,9 @@ const char *audio_driver_find_ident(int idx)
|
|||||||
*
|
*
|
||||||
* Returns: string listing of all audio driver names, separated by '|'.
|
* Returns: string listing of all audio driver names, separated by '|'.
|
||||||
**/
|
**/
|
||||||
const char* config_get_audio_driver_options(void)
|
const char *config_get_audio_driver_options(void)
|
||||||
{
|
{
|
||||||
union string_list_elem_attr attr;
|
return string_list_special_new(STRING_LIST_AUDIO_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; audio_driver_find_handle(i); i++)
|
|
||||||
{
|
|
||||||
const char *opt = audio_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)
|
|
||||||
{
|
|
||||||
options = NULL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
string_list_join_concat(options, options_len, options_l, "|");
|
|
||||||
|
|
||||||
end:
|
|
||||||
string_list_free(options_l);
|
|
||||||
options_l = NULL;
|
|
||||||
|
|
||||||
return options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_audio_driver(void)
|
void find_audio_driver(void)
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "camera/camera_driver.h"
|
#include "camera/camera_driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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)
|
||||||
{
|
{
|
||||||
union string_list_elem_attr attr;
|
union string_list_elem_attr attr;
|
||||||
@ -63,6 +65,15 @@ const char *string_list_special_new(enum string_list_type type)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case STRING_LIST_AUDIO_DRIVERS:
|
||||||
|
for (i = 0; audio_driver_find_handle(i); i++)
|
||||||
|
{
|
||||||
|
const char *opt = audio_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;
|
||||||
|
@ -20,7 +20,8 @@ enum string_list_type
|
|||||||
{
|
{
|
||||||
STRING_LIST_NONE = 0,
|
STRING_LIST_NONE = 0,
|
||||||
STRING_LIST_MENU_DRIVERS,
|
STRING_LIST_MENU_DRIVERS,
|
||||||
STRING_LIST_CAMERA_DRIVERS
|
STRING_LIST_CAMERA_DRIVERS,
|
||||||
|
STRING_LIST_AUDIO_DRIVERS
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *string_list_special_new(enum string_list_type type);
|
const char *string_list_special_new(enum string_list_type type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user