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.
This commit is contained in:
poljar (Damir Jelić) 2013-06-26 16:09:08 +02:00
parent 2d9aba0946
commit 83cf44831f

View file

@ -213,14 +213,21 @@ static pa_resample_method_t pa_resampler_fix_method(
method = PA_RESAMPLER_AUTO; method = PA_RESAMPLER_AUTO;
} }
if (method == PA_RESAMPLER_FFMPEG && (flags & PA_RESAMPLER_VARIABLE_RATE)) { switch (method) {
pa_log_info("Resampler 'ffmpeg' cannot do variable rate, reverting to resampler 'auto'."); case PA_RESAMPLER_COPY:
method = PA_RESAMPLER_AUTO; if (rate_a != rate_b) {
} pa_log_info("Resampler 'copy' cannot change sampling rate, reverting to resampler 'auto'.");
break;
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'."); /* Else fall through */
method = PA_RESAMPLER_AUTO; 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) { if (method == PA_RESAMPLER_AUTO) {