aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--NEWS1
-rw-r--r--doc/mpd.conf.55
-rw-r--r--src/pcm_resample.c48
-rw-r--r--src/pcm_resample_internal.h4
5 files changed, 41 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am
index 508cba28b..9c0245923 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -198,6 +198,7 @@ src_mpd_SOURCES = \
src/pcm_channels.c \
src/pcm_format.c \
src/pcm_resample.c \
+ src/pcm_resample_fallback.c \
src/pcm_dither.c \
src/permission.c \
src/player_thread.c \
@@ -240,8 +241,6 @@ endif
if HAVE_LIBSAMPLERATE
src_mpd_SOURCES += src/pcm_resample_libsamplerate.c
-else
-src_mpd_SOURCES += src/pcm_resample_fallback.c
endif
if HAVE_ID3TAG
diff --git a/NEWS b/NEWS
index 12e671e1c..4da735343 100644
--- a/NEWS
+++ b/NEWS
@@ -53,6 +53,7 @@ ver 0.15 - (200?/??/??)
* 32 bit audio support
* Print available protocols in --version
* fill buffer after seeking
+* choose the fallback resampler at runtime
ver 0.14.2 (2009/02/13)
diff --git a/doc/mpd.conf.5 b/doc/mpd.conf.5
index 592398a10..c66937513 100644
--- a/doc/mpd.conf.5
+++ b/doc/mpd.conf.5
@@ -158,6 +158,11 @@ distortions.
Linear Interpolator (4)
Linear interpolator, very fast, poor quality.
+.TP
+internal
+
+Poor quality, no floating point operations. This is the default (and
+only choice) if MPD was compiled without libsamplerate.
.RE
.IP
For an up-to-date list of available converters, please see the libsamplerate
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
}
diff --git a/src/pcm_resample_internal.h b/src/pcm_resample_internal.h
index af62b7663..a10ba08cd 100644
--- a/src/pcm_resample_internal.h
+++ b/src/pcm_resample_internal.h
@@ -52,7 +52,7 @@ pcm_resample_lsr_32(struct pcm_resample_state *state,
unsigned dest_rate,
size_t *dest_size_r);
-#else
+#endif
void
pcm_resample_fallback_deinit(struct pcm_resample_state *state);
@@ -75,5 +75,3 @@ pcm_resample_fallback_32(struct pcm_resample_state *state,
size_t *dest_size_r);
#endif
-
-#endif