(audio/dsp_filter.c) Cleanups

This commit is contained in:
twinaphex 2015-01-07 21:43:28 +01:00
parent cbfd7ad881
commit 9fee7f5c80

View File

@ -136,11 +136,13 @@ static const dspfilter_get_implementation_t dsp_plugs_builtin[] = {
chorus_dspfilter_get_implementation, chorus_dspfilter_get_implementation,
}; };
static bool append_plugs(rarch_dsp_filter_t *dsp) static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
{ {
unsigned i; unsigned i;
dspfilter_simd_mask_t mask = rarch_get_cpu_features(); dspfilter_simd_mask_t mask = rarch_get_cpu_features();
(void)list;
dsp->plugs = (struct rarch_dsp_plug*) dsp->plugs = (struct rarch_dsp_plug*)
calloc(ARRAY_SIZE(dsp_plugs_builtin), sizeof(*dsp->plugs)); calloc(ARRAY_SIZE(dsp_plugs_builtin), sizeof(*dsp->plugs));
if (!dsp->plugs) if (!dsp->plugs)
@ -212,12 +214,13 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
rarch_dsp_filter_t *rarch_dsp_filter_new( rarch_dsp_filter_t *rarch_dsp_filter_new(
const char *filter_config, float sample_rate) const char *filter_config, float sample_rate)
{ {
#if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
char basedir[PATH_MAX]; char basedir[PATH_MAX];
#endif
struct string_list *plugs = NULL; struct string_list *plugs = NULL;
rarch_dsp_filter_t *dsp = NULL;
rarch_dsp_filter_t *dsp = (rarch_dsp_filter_t*)calloc(1, sizeof(*dsp)); (void)basedir;
dsp = (rarch_dsp_filter_t*)calloc(1, sizeof(*dsp));
if (!dsp) if (!dsp)
return NULL; return NULL;
@ -228,22 +231,19 @@ rarch_dsp_filter_t *rarch_dsp_filter_new(
goto error; goto error;
} }
#if defined(HAVE_FILTERS_BUILTIN) #if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
if (!append_plugs(dsp))
goto error;
#elif defined(HAVE_DYLIB)
fill_pathname_basedir(basedir, filter_config, sizeof(basedir)); fill_pathname_basedir(basedir, filter_config, sizeof(basedir));
plugs = dir_list_new(basedir, EXT_EXECUTABLES, false); plugs = dir_list_new(basedir, EXT_EXECUTABLES, false);
if (!plugs) if (!plugs)
goto error; goto error;
#endif
if (!append_plugs(dsp, plugs)) if (!append_plugs(dsp, plugs))
goto error; goto error;
if (plugs)
string_list_free(plugs); string_list_free(plugs);
plugs = NULL; plugs = NULL;
#endif
if (!create_filter_graph(dsp, sample_rate)) if (!create_filter_graph(dsp, sample_rate))
goto error; goto error;
@ -251,6 +251,7 @@ rarch_dsp_filter_t *rarch_dsp_filter_new(
return dsp; return dsp;
error: error:
if (plugs)
string_list_free(plugs); string_list_free(plugs);
rarch_dsp_filter_free(dsp); rarch_dsp_filter_free(dsp);
return NULL; return NULL;