From 2b3fd0d4d34be365e44fd53b3bf3c72f8b0a69ea Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 8 Oct 2011 13:14:29 +0200 Subject: pcm_resample: one-time global initialization Load the samplerate_converter on MPD startup. Fail if the converter name is invalid. --- src/pcm_resample.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/pcm_resample.c') diff --git a/src/pcm_resample.c b/src/pcm_resample.c index a1e4ee149..ce75325a8 100644 --- a/src/pcm_resample.c +++ b/src/pcm_resample.c @@ -26,15 +26,36 @@ #include +#ifdef HAVE_LIBSAMPLERATE +static bool lsr_enabled; +#endif + #ifdef HAVE_LIBSAMPLERATE static bool pcm_resample_lsr_enabled(void) { - return strcmp(config_get_string(CONF_SAMPLERATE_CONVERTER, ""), - "internal") != 0; + return lsr_enabled; } #endif +bool +pcm_resample_global_init(GError **error_r) +{ +#ifdef HAVE_LIBSAMPLERATE + const char *converter = + config_get_string(CONF_SAMPLERATE_CONVERTER, ""); + + lsr_enabled = strcmp(converter, "internal") != 0; + if (lsr_enabled) + return pcm_resample_lsr_global_init(converter, error_r); + else + return true; +#else + (void)error_r; + return true; +#endif +} + void pcm_resample_init(struct pcm_resample_state *state) { memset(state, 0, sizeof(*state)); -- cgit v1.2.3