aboutsummaryrefslogtreecommitdiff
path: root/src/pcm_resample.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-10-08 13:14:29 +0200
committerMax Kellermann <max@duempel.org>2011-10-08 13:14:29 +0200
commit2b3fd0d4d34be365e44fd53b3bf3c72f8b0a69ea (patch)
tree645214575b9f1aab54312120694d60c591993fce /src/pcm_resample.c
parent894b9cfdb9fb69dbdde937c32726508472601402 (diff)
pcm_resample: one-time global initialization
Load the samplerate_converter on MPD startup. Fail if the converter name is invalid.
Diffstat (limited to 'src/pcm_resample.c')
-rw-r--r--src/pcm_resample.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/pcm_resample.c b/src/pcm_resample.c
index a1e4ee14..ce75325a 100644
--- a/src/pcm_resample.c
+++ b/src/pcm_resample.c
@@ -27,14 +27,35 @@
#include <string.h>
#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));