This function returns our preferred resampler if the user choose the auto (or if he has chosen an unsupported) resampler. --- src/pulsecore/resampler.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c index c4434ff..eb1ee6c 100644 --- a/src/pulsecore/resampler.c +++ b/src/pulsecore/resampler.c @@ -182,6 +182,19 @@ static pa_resampler_implementation *impl_table[] = { [PA_RESAMPLER_PEAKS] = &peaks_impl, }; +static pa_resample_method_t choose_auto_resampler(pa_resample_flags_t flags) { + pa_resample_method_t method; + + if (pa_resample_method_supported(PA_RESAMPLER_SPEEX_FLOAT_BASE + 1)) + method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 1; + else if (flags & PA_RESAMPLER_VARIABLE_RATE) + method = PA_RESAMPLER_TRIVIAL; + else + method = PA_RESAMPLER_FFMPEG; + + return method; +} + static pa_resample_method_t pa_resampler_fix_method( pa_resample_flags_t flags, pa_resample_method_t method, @@ -225,16 +238,8 @@ static pa_resample_method_t pa_resampler_fix_method( break; } - if (method == PA_RESAMPLER_AUTO) { -#ifdef HAVE_SPEEX - method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 1; -#else - if (flags & PA_RESAMPLER_VARIABLE_RATE) - method = PA_RESAMPLER_TRIVIAL; - else - method = PA_RESAMPLER_FFMPEG; -#endif - } + if (method == PA_RESAMPLER_AUTO) + method = choose_auto_resampler(flags); return method; } -- 1.8.3.2