From 7452a48864aa6bd385a13a13e6fb631ae98c6501 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 25 Feb 2014 02:55:05 +0100 Subject: [PATCH] Add back resampler selection code --- audio/resampler.c | 26 ++++++++++++++++++++++++-- audio/resampler.h | 4 ---- config.def.h | 3 +++ retroarch.cfg | 4 ++++ settings.c | 3 +++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/audio/resampler.c b/audio/resampler.c index a9fed17aa6..8b624a141d 100644 --- a/audio/resampler.c +++ b/audio/resampler.c @@ -22,12 +22,35 @@ #include "../general.h" +static const rarch_resampler_t *backends[] = { + &sinc_resampler, +}; + bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const char *ident, double bw_ratio) { if (*re && *backend) (*backend)->free(*re); - *backend = &sinc_resampler; + *re = NULL; + *backend = NULL; + + if (ident) + { + for (unsigned i = 0; i < ARRAY_SIZE(backends); i++) + { + if (strcmp(backends[i]->ident, ident) == 0) + { + *backend = backends[i]; + break; + } + } + } + else + *backend = backends[0]; + + if (!*backend) + return false; + *re = (*backend)->init(bw_ratio); if (!*re) @@ -38,4 +61,3 @@ bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const return true; } - diff --git a/audio/resampler.h b/audio/resampler.h index c862f579e3..d1e66fd9a9 100644 --- a/audio/resampler.h +++ b/audio/resampler.h @@ -65,13 +65,9 @@ bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const *handle = NULL; \ } while(0) -#ifdef RARCH_CONSOLE -#define rarch_resampler_process(backend, handle, data) resampler_sinc_process(handle, data) -#else #define rarch_resampler_process(backend, handle, data) do { \ (backend)->process(handle, data); \ } while(0) -#endif #endif diff --git a/config.def.h b/config.def.h index 8b70344254..c0f7f6905f 100644 --- a/config.def.h +++ b/config.def.h @@ -442,6 +442,9 @@ static const int out_latency = 64; // Will sync audio. (recommended) static const bool audio_sync = true; +// Default resampler +static const char *audio_resampler = "sinc"; + // Experimental rate control #if defined(GEKKO) || !defined(RARCH_CONSOLE) static const bool rate_control = true; diff --git a/retroarch.cfg b/retroarch.cfg index 6afcc7861e..235b506982 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -194,6 +194,10 @@ # Audio output samplerate. # audio_out_rate = 48000 +# Which resampler to use. +# Default will use "sinc". +# audio_resampler = + # Audio driver backend. Depending on configuration possible candidates are: alsa, pulse, oss, jack, rsound, roar, openal, sdl, xaudio. # audio_driver = diff --git a/settings.c b/settings.c index 205f689edc..3c24feb097 100644 --- a/settings.c +++ b/settings.c @@ -290,6 +290,7 @@ void config_set_defaults(void) g_settings.audio.volume = audio_volume; g_extern.audio_data.volume_db = g_settings.audio.volume; g_extern.audio_data.volume_gain = db_to_gain(g_settings.audio.volume); + strlcpy(g_settings.audio.resampler, audio_resampler, sizeof(g_settings.audio.resampler)); g_settings.rewind_enable = rewind_enable; g_settings.rewind_buffer_size = rewind_buffer_size; @@ -892,6 +893,7 @@ bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL(audio.rate_control, "audio_rate_control"); CONFIG_GET_FLOAT(audio.rate_control_delta, "audio_rate_control_delta"); CONFIG_GET_FLOAT(audio.volume, "audio_volume"); + CONFIG_GET_STRING(audio.resampler, "audio_resampler"); g_extern.audio_data.volume_db = g_settings.audio.volume; g_extern.audio_data.volume_gain = db_to_gain(g_settings.audio.volume); @@ -1271,6 +1273,7 @@ bool config_save_file(const char *path) config_set_int(conf, "audio_out_rate", g_settings.audio.out_rate); config_set_path(conf, "system_directory", *g_settings.system_directory ? g_settings.system_directory : "default"); + config_set_string(conf, "audio_resampler", g_settings.audio.resampler); config_set_path(conf, "savefile_directory", *g_extern.savefile_dir ? g_extern.savefile_dir : "default"); config_set_path(conf, "savestate_directory", *g_extern.savestate_dir ? g_extern.savestate_dir : "default"); config_set_path(conf, "video_shader_dir", *g_settings.video.shader_dir ? g_settings.video.shader_dir : "default");