From 83cf44831f821962e9428e8faec9bd7b89ff39fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Wed, 26 Jun 2013 16:09:08 +0200 Subject: [PATCH] resampler: fix_method use switch instead of if/else This way the fix method function should be more readable and easier to expand in the future. --- src/pulsecore/resampler.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c index 00682c73a..fcc52e642 100644 --- a/src/pulsecore/resampler.c +++ b/src/pulsecore/resampler.c @@ -213,14 +213,21 @@ static pa_resample_method_t pa_resampler_fix_method( method = PA_RESAMPLER_AUTO; } - if (method == PA_RESAMPLER_FFMPEG && (flags & PA_RESAMPLER_VARIABLE_RATE)) { - pa_log_info("Resampler 'ffmpeg' cannot do variable rate, reverting to resampler 'auto'."); - method = PA_RESAMPLER_AUTO; - } - - if (method == PA_RESAMPLER_COPY && ((flags & PA_RESAMPLER_VARIABLE_RATE) || a->rate != b->rate)) { - pa_log_info("Resampler 'copy' cannot change sampling rate, reverting to resampler 'auto'."); - method = PA_RESAMPLER_AUTO; + switch (method) { + case PA_RESAMPLER_COPY: + if (rate_a != rate_b) { + pa_log_info("Resampler 'copy' cannot change sampling rate, reverting to resampler 'auto'."); + break; + } + /* Else fall through */ + case PA_RESAMPLER_FFMPEG: + if (flags & PA_RESAMPLER_VARIABLE_RATE) { + pa_log_info("Resampler '%s' cannot do variable rate, reverting to resampler 'auto'.", pa_resample_method_to_string(method)); + method = PA_RESAMPLER_AUTO; + } + break; + default: + break; } if (method == PA_RESAMPLER_AUTO) {