resampler: Use pa_xnew0() to avoid manual zeroing.

This commit is contained in:
Tanu Kaskinen 2012-05-10 09:19:21 +03:00 committed by Arun Raghavan
parent a6394b1cb0
commit 7921a851eb

View file

@ -234,16 +234,11 @@ pa_resampler* pa_resampler_new(
#endif #endif
} }
r = pa_xnew(pa_resampler, 1); r = pa_xnew0(pa_resampler, 1);
r->mempool = pool; r->mempool = pool;
r->method = method; r->method = method;
r->flags = flags; r->flags = flags;
r->impl_free = NULL;
r->impl_update_rates = NULL;
r->impl_resample = NULL;
r->impl_reset = NULL;
/* Fill sample specs */ /* Fill sample specs */
r->i_ss = *a; r->i_ss = *a;
r->o_ss = *b; r->o_ss = *b;
@ -266,13 +261,6 @@ pa_resampler* pa_resampler_new(
r->i_fz = pa_frame_size(a); r->i_fz = pa_frame_size(a);
r->o_fz = pa_frame_size(b); 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); calc_map_table(r);
pa_log_info("Using resampler '%s'", pa_resample_method_to_string(method)); pa_log_info("Using resampler '%s'", pa_resample_method_to_string(method));
@ -306,26 +294,26 @@ pa_resampler* pa_resampler_new(
r->w_sz = pa_sample_size_of_format(r->work_format); r->w_sz = pa_sample_size_of_format(r->work_format);
if (r->i_ss.format == r->work_format) if (r->i_ss.format != r->work_format) {
r->to_work_format_func = NULL; if (r->work_format == PA_SAMPLE_FLOAT32NE) {
else if (r->work_format == PA_SAMPLE_FLOAT32NE) { if (!(r->to_work_format_func = pa_get_convert_to_float32ne_function(r->i_ss.format)))
if (!(r->to_work_format_func = pa_get_convert_to_float32ne_function(r->i_ss.format))) goto fail;
goto fail; } else {
} else { pa_assert(r->work_format == PA_SAMPLE_S16NE);
pa_assert(r->work_format == PA_SAMPLE_S16NE); if (!(r->to_work_format_func = pa_get_convert_to_s16ne_function(r->i_ss.format)))
if (!(r->to_work_format_func = pa_get_convert_to_s16ne_function(r->i_ss.format))) goto fail;
goto fail; }
} }
if (r->o_ss.format == r->work_format) if (r->o_ss.format != r->work_format) {
r->from_work_format_func = NULL; if (r->work_format == PA_SAMPLE_FLOAT32NE) {
else if (r->work_format == PA_SAMPLE_FLOAT32NE) { if (!(r->from_work_format_func = pa_get_convert_from_float32ne_function(r->o_ss.format)))
if (!(r->from_work_format_func = pa_get_convert_from_float32ne_function(r->o_ss.format))) goto fail;
goto fail; } else {
} else { pa_assert(r->work_format == PA_SAMPLE_S16NE);
pa_assert(r->work_format == PA_SAMPLE_S16NE); if (!(r->from_work_format_func = pa_get_convert_from_s16ne_function(r->o_ss.format)))
if (!(r->from_work_format_func = pa_get_convert_from_s16ne_function(r->o_ss.format))) goto fail;
goto fail; }
} }
/* initialize implementation */ /* initialize implementation */