mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
resampler: Use pa_xnew0() to avoid manual zeroing.
This commit is contained in:
parent
a6394b1cb0
commit
7921a851eb
1 changed files with 19 additions and 31 deletions
|
|
@ -234,16 +234,11 @@ pa_resampler* pa_resampler_new(
|
|||
#endif
|
||||
}
|
||||
|
||||
r = pa_xnew(pa_resampler, 1);
|
||||
r = pa_xnew0(pa_resampler, 1);
|
||||
r->mempool = pool;
|
||||
r->method = method;
|
||||
r->flags = flags;
|
||||
|
||||
r->impl_free = NULL;
|
||||
r->impl_update_rates = NULL;
|
||||
r->impl_resample = NULL;
|
||||
r->impl_reset = NULL;
|
||||
|
||||
/* Fill sample specs */
|
||||
r->i_ss = *a;
|
||||
r->o_ss = *b;
|
||||
|
|
@ -266,13 +261,6 @@ pa_resampler* pa_resampler_new(
|
|||
r->i_fz = pa_frame_size(a);
|
||||
r->o_fz = pa_frame_size(b);
|
||||
|
||||
pa_memchunk_reset(&r->buf1);
|
||||
pa_memchunk_reset(&r->buf2);
|
||||
pa_memchunk_reset(&r->buf3);
|
||||
pa_memchunk_reset(&r->buf4);
|
||||
|
||||
r->buf1_samples = r->buf2_samples = r->buf3_samples = r->buf4_samples = 0;
|
||||
|
||||
calc_map_table(r);
|
||||
|
||||
pa_log_info("Using resampler '%s'", pa_resample_method_to_string(method));
|
||||
|
|
@ -306,9 +294,8 @@ pa_resampler* pa_resampler_new(
|
|||
|
||||
r->w_sz = pa_sample_size_of_format(r->work_format);
|
||||
|
||||
if (r->i_ss.format == r->work_format)
|
||||
r->to_work_format_func = NULL;
|
||||
else if (r->work_format == PA_SAMPLE_FLOAT32NE) {
|
||||
if (r->i_ss.format != r->work_format) {
|
||||
if (r->work_format == PA_SAMPLE_FLOAT32NE) {
|
||||
if (!(r->to_work_format_func = pa_get_convert_to_float32ne_function(r->i_ss.format)))
|
||||
goto fail;
|
||||
} else {
|
||||
|
|
@ -316,10 +303,10 @@ pa_resampler* pa_resampler_new(
|
|||
if (!(r->to_work_format_func = pa_get_convert_to_s16ne_function(r->i_ss.format)))
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (r->o_ss.format == r->work_format)
|
||||
r->from_work_format_func = NULL;
|
||||
else if (r->work_format == PA_SAMPLE_FLOAT32NE) {
|
||||
if (r->o_ss.format != r->work_format) {
|
||||
if (r->work_format == PA_SAMPLE_FLOAT32NE) {
|
||||
if (!(r->from_work_format_func = pa_get_convert_from_float32ne_function(r->o_ss.format)))
|
||||
goto fail;
|
||||
} else {
|
||||
|
|
@ -327,6 +314,7 @@ pa_resampler* pa_resampler_new(
|
|||
if (!(r->from_work_format_func = pa_get_convert_from_s16ne_function(r->o_ss.format)))
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize implementation */
|
||||
if (init_table[method](r) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue