diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2012-05-10 09:19:21 +0300 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2012-05-11 16:26:38 +0530 |
commit | 7921a851ebea998e67527f05708971aba9bb4e61 (patch) | |
tree | 38bc047eec773e8b1855e02a400c2a2517140411 | |
parent | a6394b1cb0fe575bdf04fb125e0cccbc518466b6 (diff) |
resampler: Use pa_xnew0() to avoid manual zeroing.
-rw-r--r-- | src/pulsecore/resampler.c | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c index 9a651f4a..185095b5 100644 --- a/src/pulsecore/resampler.c +++ b/src/pulsecore/resampler.c @@ -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,26 +294,26 @@ 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->to_work_format_func = pa_get_convert_to_float32ne_function(r->i_ss.format))) - goto fail; - } else { - pa_assert(r->work_format == PA_SAMPLE_S16NE); - if (!(r->to_work_format_func = pa_get_convert_to_s16ne_function(r->i_ss.format))) - goto fail; + 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 { + pa_assert(r->work_format == PA_SAMPLE_S16NE); + 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->from_work_format_func = pa_get_convert_from_float32ne_function(r->o_ss.format))) - goto fail; - } else { - pa_assert(r->work_format == PA_SAMPLE_S16NE); - if (!(r->from_work_format_func = pa_get_convert_from_s16ne_function(r->o_ss.format))) - goto fail; + 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 { + pa_assert(r->work_format == PA_SAMPLE_S16NE); + if (!(r->from_work_format_func = pa_get_convert_from_s16ne_function(r->o_ss.format))) + goto fail; + } } /* initialize implementation */ |