mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
resampler: Move the fix method logic into a separate function
This commit is contained in:
parent
97feeab40c
commit
2d9aba0946
1 changed files with 32 additions and 18 deletions
|
|
@ -192,28 +192,18 @@ static int (* const init_table[])(pa_resampler*r) = {
|
||||||
[PA_RESAMPLER_PEAKS] = peaks_init,
|
[PA_RESAMPLER_PEAKS] = peaks_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
pa_resampler* pa_resampler_new(
|
static pa_resample_method_t pa_resampler_fix_method(
|
||||||
pa_mempool *pool,
|
pa_resample_flags_t flags,
|
||||||
const pa_sample_spec *a,
|
|
||||||
const pa_channel_map *am,
|
|
||||||
const pa_sample_spec *b,
|
|
||||||
const pa_channel_map *bm,
|
|
||||||
pa_resample_method_t method,
|
pa_resample_method_t method,
|
||||||
pa_resample_flags_t flags) {
|
const uint32_t rate_a,
|
||||||
|
const uint32_t rate_b) {
|
||||||
|
|
||||||
pa_resampler *r = NULL;
|
pa_assert(rate_a > 0 && rate_a <= PA_RATE_MAX);
|
||||||
|
pa_assert(rate_b > 0 && rate_b <= PA_RATE_MAX);
|
||||||
pa_assert(pool);
|
|
||||||
pa_assert(a);
|
|
||||||
pa_assert(b);
|
|
||||||
pa_assert(pa_sample_spec_valid(a));
|
|
||||||
pa_assert(pa_sample_spec_valid(b));
|
|
||||||
pa_assert(method >= 0);
|
pa_assert(method >= 0);
|
||||||
pa_assert(method < PA_RESAMPLER_MAX);
|
pa_assert(method < PA_RESAMPLER_MAX);
|
||||||
|
|
||||||
/* Fix method */
|
if (!(flags & PA_RESAMPLER_VARIABLE_RATE) && rate_a == rate_b) {
|
||||||
|
|
||||||
if (!(flags & PA_RESAMPLER_VARIABLE_RATE) && a->rate == b->rate) {
|
|
||||||
pa_log_info("Forcing resampler 'copy', because of fixed, identical sample rates.");
|
pa_log_info("Forcing resampler 'copy', because of fixed, identical sample rates.");
|
||||||
method = PA_RESAMPLER_COPY;
|
method = PA_RESAMPLER_COPY;
|
||||||
}
|
}
|
||||||
|
|
@ -244,6 +234,30 @@ pa_resampler* pa_resampler_new(
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_resampler* pa_resampler_new(
|
||||||
|
pa_mempool *pool,
|
||||||
|
const pa_sample_spec *a,
|
||||||
|
const pa_channel_map *am,
|
||||||
|
const pa_sample_spec *b,
|
||||||
|
const pa_channel_map *bm,
|
||||||
|
pa_resample_method_t method,
|
||||||
|
pa_resample_flags_t flags) {
|
||||||
|
|
||||||
|
pa_resampler *r = NULL;
|
||||||
|
|
||||||
|
pa_assert(pool);
|
||||||
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
|
pa_assert(pa_sample_spec_valid(a));
|
||||||
|
pa_assert(pa_sample_spec_valid(b));
|
||||||
|
pa_assert(method >= 0);
|
||||||
|
pa_assert(method < PA_RESAMPLER_MAX);
|
||||||
|
|
||||||
|
method = pa_resampler_fix_method(flags, method, a->rate, b->rate);
|
||||||
|
|
||||||
r = pa_xnew0(pa_resampler, 1);
|
r = pa_xnew0(pa_resampler, 1);
|
||||||
r->mempool = pool;
|
r->mempool = pool;
|
||||||
r->method = method;
|
r->method = method;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue