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.
This commit is contained in:
parent
456201fa22
commit
e12140cfce
|
@ -198,6 +198,7 @@ src_mpd_SOURCES = \
|
||||||
src/pcm_channels.c \
|
src/pcm_channels.c \
|
||||||
src/pcm_format.c \
|
src/pcm_format.c \
|
||||||
src/pcm_resample.c \
|
src/pcm_resample.c \
|
||||||
|
src/pcm_resample_fallback.c \
|
||||||
src/pcm_dither.c \
|
src/pcm_dither.c \
|
||||||
src/permission.c \
|
src/permission.c \
|
||||||
src/player_thread.c \
|
src/player_thread.c \
|
||||||
|
@ -240,8 +241,6 @@ endif
|
||||||
|
|
||||||
if HAVE_LIBSAMPLERATE
|
if HAVE_LIBSAMPLERATE
|
||||||
src_mpd_SOURCES += src/pcm_resample_libsamplerate.c
|
src_mpd_SOURCES += src/pcm_resample_libsamplerate.c
|
||||||
else
|
|
||||||
src_mpd_SOURCES += src/pcm_resample_fallback.c
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HAVE_ID3TAG
|
if HAVE_ID3TAG
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -53,6 +53,7 @@ ver 0.15 - (200?/??/??)
|
||||||
* 32 bit audio support
|
* 32 bit audio support
|
||||||
* Print available protocols in --version
|
* Print available protocols in --version
|
||||||
* fill buffer after seeking
|
* fill buffer after seeking
|
||||||
|
* choose the fallback resampler at runtime
|
||||||
|
|
||||||
|
|
||||||
ver 0.14.2 (2009/02/13)
|
ver 0.14.2 (2009/02/13)
|
||||||
|
|
|
@ -158,6 +158,11 @@ distortions.
|
||||||
Linear Interpolator (4)
|
Linear Interpolator (4)
|
||||||
|
|
||||||
Linear interpolator, very fast, poor quality.
|
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
|
.RE
|
||||||
.IP
|
.IP
|
||||||
For an up-to-date list of available converters, please see the libsamplerate
|
For an up-to-date list of available converters, please see the libsamplerate
|
||||||
|
|
|
@ -20,15 +20,30 @@
|
||||||
#include "pcm_resample_internal.h"
|
#include "pcm_resample_internal.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBSAMPLERATE
|
||||||
|
#include "conf.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#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)
|
void pcm_resample_init(struct pcm_resample_state *state)
|
||||||
{
|
{
|
||||||
memset(state, 0, sizeof(*state));
|
memset(state, 0, sizeof(*state));
|
||||||
|
|
||||||
#ifdef HAVE_LIBSAMPLERATE
|
#ifdef HAVE_LIBSAMPLERATE
|
||||||
pcm_buffer_init(&state->in);
|
if (pcm_resample_lsr_enabled()) {
|
||||||
pcm_buffer_init(&state->out);
|
pcm_buffer_init(&state->in);
|
||||||
|
pcm_buffer_init(&state->out);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pcm_buffer_init(&state->buffer);
|
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)
|
void pcm_resample_deinit(struct pcm_resample_state *state)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBSAMPLERATE
|
#ifdef HAVE_LIBSAMPLERATE
|
||||||
pcm_resample_lsr_deinit(state);
|
if (pcm_resample_lsr_enabled())
|
||||||
#else
|
pcm_resample_lsr_deinit(state);
|
||||||
pcm_resample_fallback_deinit(state);
|
else
|
||||||
#endif
|
#endif
|
||||||
|
pcm_resample_fallback_deinit(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int16_t *
|
const int16_t *
|
||||||
|
@ -52,14 +68,15 @@ pcm_resample_16(struct pcm_resample_state *state,
|
||||||
size_t *dest_size_r)
|
size_t *dest_size_r)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBSAMPLERATE
|
#ifdef HAVE_LIBSAMPLERATE
|
||||||
return pcm_resample_lsr_16(state, channels,
|
if (pcm_resample_lsr_enabled())
|
||||||
src_rate, src_buffer, src_size,
|
return pcm_resample_lsr_16(state, channels,
|
||||||
dest_rate, dest_size_r);
|
src_rate, src_buffer, src_size,
|
||||||
#else
|
dest_rate, dest_size_r);
|
||||||
|
#endif
|
||||||
|
|
||||||
return pcm_resample_fallback_16(state, channels,
|
return pcm_resample_fallback_16(state, channels,
|
||||||
src_rate, src_buffer, src_size,
|
src_rate, src_buffer, src_size,
|
||||||
dest_rate, dest_size_r);
|
dest_rate, dest_size_r);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int32_t *
|
const int32_t *
|
||||||
|
@ -71,12 +88,13 @@ pcm_resample_32(struct pcm_resample_state *state,
|
||||||
size_t *dest_size_r)
|
size_t *dest_size_r)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBSAMPLERATE
|
#ifdef HAVE_LIBSAMPLERATE
|
||||||
return pcm_resample_lsr_32(state, channels,
|
if (pcm_resample_lsr_enabled())
|
||||||
src_rate, src_buffer, src_size,
|
return pcm_resample_lsr_32(state, channels,
|
||||||
dest_rate, dest_size_r);
|
src_rate, src_buffer, src_size,
|
||||||
#else
|
dest_rate, dest_size_r);
|
||||||
|
#endif
|
||||||
|
|
||||||
return pcm_resample_fallback_32(state, channels,
|
return pcm_resample_fallback_32(state, channels,
|
||||||
src_rate, src_buffer, src_size,
|
src_rate, src_buffer, src_size,
|
||||||
dest_rate, dest_size_r);
|
dest_rate, dest_size_r);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ pcm_resample_lsr_32(struct pcm_resample_state *state,
|
||||||
unsigned dest_rate,
|
unsigned dest_rate,
|
||||||
size_t *dest_size_r);
|
size_t *dest_size_r);
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
pcm_resample_fallback_deinit(struct pcm_resample_state *state);
|
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);
|
size_t *dest_size_r);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue