aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_resample.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pcm_resample.c')
-rw-r--r--src/pcm_resample.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/pcm_resample.c b/src/pcm_resample.c
index 4a7578e09..d4b117c56 100644
--- a/src/pcm_resample.c
+++ b/src/pcm_resample.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -27,26 +27,43 @@
#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
-void pcm_resample_init(struct pcm_resample_state *state)
+bool
+pcm_resample_global_init(GError **error_r)
{
- memset(state, 0, sizeof(*state));
-
#ifdef HAVE_LIBSAMPLERATE
- if (pcm_resample_lsr_enabled()) {
- pcm_buffer_init(&state->in);
- pcm_buffer_init(&state->out);
- }
+ 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
+}
- pcm_buffer_init(&state->buffer);
+void pcm_resample_init(struct pcm_resample_state *state)
+{
+#ifdef HAVE_LIBSAMPLERATE
+ if (pcm_resample_lsr_enabled())
+ pcm_resample_lsr_init(state);
+ else
+#endif
+ pcm_resample_fallback_init(state);
}
void pcm_resample_deinit(struct pcm_resample_state *state)