Add back resampler selection code

This commit is contained in:
twinaphex 2014-02-25 02:55:05 +01:00
parent 2489e2fef0
commit 7452a48864
5 changed files with 34 additions and 6 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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 =

View File

@ -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");