mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
resampler: choose_work_format use switch instead of if/else
This way the function for choosing the work format should be more readable and easier to expand in the future.
This commit is contained in:
parent
78c18e71e0
commit
7665f60cc0
1 changed files with 23 additions and 10 deletions
|
|
@ -256,13 +256,27 @@ static pa_sample_format_t pa_resampler_choose_work_format(
|
||||||
pa_assert(method >= 0);
|
pa_assert(method >= 0);
|
||||||
pa_assert(method < PA_RESAMPLER_MAX);
|
pa_assert(method < PA_RESAMPLER_MAX);
|
||||||
|
|
||||||
if ((method >= PA_RESAMPLER_SPEEX_FIXED_BASE && method <= PA_RESAMPLER_SPEEX_FIXED_MAX) ||
|
if (method >= PA_RESAMPLER_SPEEX_FIXED_BASE && method <= PA_RESAMPLER_SPEEX_FIXED_MAX)
|
||||||
(method == PA_RESAMPLER_FFMPEG))
|
method = PA_RESAMPLER_SPEEX_FIXED_BASE;
|
||||||
|
|
||||||
|
switch (method) {
|
||||||
|
/* This block is for resampling functions that only
|
||||||
|
* support the S16 sample format. */
|
||||||
|
case PA_RESAMPLER_SPEEX_FIXED_BASE: /* fall through */
|
||||||
|
case PA_RESAMPLER_FFMPEG:
|
||||||
work_format = PA_SAMPLE_S16NE;
|
work_format = PA_SAMPLE_S16NE;
|
||||||
else if (method == PA_RESAMPLER_TRIVIAL || method == PA_RESAMPLER_COPY || method == PA_RESAMPLER_PEAKS) {
|
break;
|
||||||
|
|
||||||
if (map_required || a != b || method == PA_RESAMPLER_PEAKS) {
|
|
||||||
|
|
||||||
|
/* This block is for resampling functions that support
|
||||||
|
* any sample format. */
|
||||||
|
case PA_RESAMPLER_COPY: /* fall through */
|
||||||
|
case PA_RESAMPLER_TRIVIAL:
|
||||||
|
if (!map_required && a == b) {
|
||||||
|
work_format = a;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Else fall trough */
|
||||||
|
case PA_RESAMPLER_PEAKS:
|
||||||
if (a == PA_SAMPLE_S16NE || b == PA_SAMPLE_S16NE)
|
if (a == PA_SAMPLE_S16NE || b == PA_SAMPLE_S16NE)
|
||||||
work_format = PA_SAMPLE_S16NE;
|
work_format = PA_SAMPLE_S16NE;
|
||||||
else if (a == PA_SAMPLE_S32NE || a == PA_SAMPLE_S32RE ||
|
else if (a == PA_SAMPLE_S32NE || a == PA_SAMPLE_S32RE ||
|
||||||
|
|
@ -276,12 +290,11 @@ static pa_sample_format_t pa_resampler_choose_work_format(
|
||||||
work_format = PA_SAMPLE_FLOAT32NE;
|
work_format = PA_SAMPLE_FLOAT32NE;
|
||||||
else
|
else
|
||||||
work_format = PA_SAMPLE_S16NE;
|
work_format = PA_SAMPLE_S16NE;
|
||||||
|
break;
|
||||||
|
|
||||||
} else
|
default:
|
||||||
work_format = a;
|
|
||||||
|
|
||||||
} else
|
|
||||||
work_format = PA_SAMPLE_FLOAT32NE;
|
work_format = PA_SAMPLE_FLOAT32NE;
|
||||||
|
}
|
||||||
|
|
||||||
return work_format;
|
return work_format;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue