aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_resample.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-14 15:26:36 +0100
committerMax Kellermann <max@duempel.org>2009-03-14 15:26:36 +0100
commite12140cfce88985f9fcecb93214a94a0b9c33e7f (patch)
tree3e5c213af02c782e67f0a0fd902c63382e2eb56a /src/pcm_resample.c
parent456201fa222ab208aba45fa2d700a56f04876886 (diff)
downloadmpd-e12140cfce88985f9fcecb93214a94a0b9c33e7f.tar.gz
mpd-e12140cfce88985f9fcecb93214a94a0b9c33e7f.tar.xz
mpd-e12140cfce88985f9fcecb93214a94a0b9c33e7f.zip
pcm_resample: choose the fallback resampler at runtime
Even if libsamplerate support is enabled, compile the fallback resampler. When the user specifies the option "samplerate_converter=internal", it is chosen in favor of libsamplerate. This may help users with a weak FPU who don't want to compile a custom MPD from source, because the fallback resampler does not use floating point operations.
Diffstat (limited to '')
-rw-r--r--src/pcm_resample.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/pcm_resample.c b/src/pcm_resample.c
index f27bf4f0c..69fda79e4 100644
--- a/src/pcm_resample.c
+++ b/src/pcm_resample.c
@@ -20,15 +20,30 @@
#include "pcm_resample_internal.h"
#include "config.h"
+#ifdef HAVE_LIBSAMPLERATE
+#include "conf.h"
+#endif
+
#include <string.h>
+#ifdef HAVE_LIBSAMPLERATE
+static bool
+pcm_resample_lsr_enabled(void)
+{
+ return strcmp(config_get_string(CONF_SAMPLERATE_CONVERTER, ""),
+ "internal") == 0;
+}
+#endif
+
void pcm_resample_init(struct pcm_resample_state *state)
{
memset(state, 0, sizeof(*state));
#ifdef HAVE_LIBSAMPLERATE
- pcm_buffer_init(&state->in);
- pcm_buffer_init(&state->out);
+ if (pcm_resample_lsr_enabled()) {
+ pcm_buffer_init(&state->in);
+ pcm_buffer_init(&state->out);
+ }
#endif
pcm_buffer_init(&state->buffer);
@@ -37,10 +52,11 @@ void pcm_resample_init(struct pcm_resample_state *state)
void pcm_resample_deinit(struct pcm_resample_state *state)
{
#ifdef HAVE_LIBSAMPLERATE
- pcm_resample_lsr_deinit(state);
-#else
- pcm_resample_fallback_deinit(state);
+ if (pcm_resample_lsr_enabled())
+ pcm_resample_lsr_deinit(state);
+ else
#endif
+ pcm_resample_fallback_deinit(state);
}
const int16_t *
@@ -52,14 +68,15 @@ pcm_resample_16(struct pcm_resample_state *state,
size_t *dest_size_r)
{
#ifdef HAVE_LIBSAMPLERATE
- return pcm_resample_lsr_16(state, channels,
- src_rate, src_buffer, src_size,
- dest_rate, dest_size_r);
-#else
+ if (pcm_resample_lsr_enabled())
+ return pcm_resample_lsr_16(state, channels,
+ src_rate, src_buffer, src_size,
+ dest_rate, dest_size_r);
+#endif
+
return pcm_resample_fallback_16(state, channels,
src_rate, src_buffer, src_size,
dest_rate, dest_size_r);
-#endif
}
const int32_t *
@@ -71,12 +88,13 @@ pcm_resample_32(struct pcm_resample_state *state,
size_t *dest_size_r)
{
#ifdef HAVE_LIBSAMPLERATE
- return pcm_resample_lsr_32(state, channels,
- src_rate, src_buffer, src_size,
- dest_rate, dest_size_r);
-#else
+ if (pcm_resample_lsr_enabled())
+ return pcm_resample_lsr_32(state, channels,
+ src_rate, src_buffer, src_size,
+ dest_rate, dest_size_r);
+#endif
+
return pcm_resample_fallback_32(state, channels,
src_rate, src_buffer, src_size,
dest_rate, dest_size_r);
-#endif
}