From 14424281a0e1407ca04ef05a50541a4178f70e91 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 8 Oct 2011 12:40:03 +0200 Subject: pcm_resample: add internal function _lsr_init() Let the libsamplerate code initialize itself. --- src/pcm_resample.c | 12 ++++-------- src/pcm_resample_fallback.c | 6 ++++++ src/pcm_resample_internal.h | 6 ++++++ src/pcm_resample_libsamplerate.c | 10 ++++++++++ 4 files changed, 26 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/pcm_resample.c b/src/pcm_resample.c index ce75325a8..d4b117c56 100644 --- a/src/pcm_resample.c +++ b/src/pcm_resample.c @@ -58,16 +58,12 @@ pcm_resample_global_init(GError **error_r) void pcm_resample_init(struct pcm_resample_state *state) { - memset(state, 0, sizeof(*state)); - #ifdef HAVE_LIBSAMPLERATE - if (pcm_resample_lsr_enabled()) { - pcm_buffer_init(&state->in); - pcm_buffer_init(&state->out); - } + if (pcm_resample_lsr_enabled()) + pcm_resample_lsr_init(state); + else #endif - - pcm_buffer_init(&state->buffer); + pcm_resample_fallback_init(state); } void pcm_resample_deinit(struct pcm_resample_state *state) diff --git a/src/pcm_resample_fallback.c b/src/pcm_resample_fallback.c index 79c2f5176..b4d9d010f 100644 --- a/src/pcm_resample_fallback.c +++ b/src/pcm_resample_fallback.c @@ -22,6 +22,12 @@ #include +void +pcm_resample_fallback_init(struct pcm_resample_state *state) +{ + pcm_buffer_init(&state->buffer); +} + void pcm_resample_fallback_deinit(struct pcm_resample_state *state) { diff --git a/src/pcm_resample_internal.h b/src/pcm_resample_internal.h index d8e0ba5a1..ea75df341 100644 --- a/src/pcm_resample_internal.h +++ b/src/pcm_resample_internal.h @@ -35,6 +35,9 @@ bool pcm_resample_lsr_global_init(const char *converter, GError **error_r); +void +pcm_resample_lsr_init(struct pcm_resample_state *state); + void pcm_resample_lsr_deinit(struct pcm_resample_state *state); @@ -57,6 +60,9 @@ pcm_resample_lsr_32(struct pcm_resample_state *state, #endif +void +pcm_resample_fallback_init(struct pcm_resample_state *state); + void pcm_resample_fallback_deinit(struct pcm_resample_state *state); diff --git a/src/pcm_resample_libsamplerate.c b/src/pcm_resample_libsamplerate.c index 769f904c1..a71659d51 100644 --- a/src/pcm_resample_libsamplerate.c +++ b/src/pcm_resample_libsamplerate.c @@ -83,6 +83,16 @@ pcm_resample_lsr_global_init(const char *converter, GError **error_r) return true; } +void +pcm_resample_lsr_init(struct pcm_resample_state *state) +{ + memset(state, 0, sizeof(*state)); + + pcm_buffer_init(&state->in); + pcm_buffer_init(&state->out); + pcm_buffer_init(&state->buffer); +} + void pcm_resample_lsr_deinit(struct pcm_resample_state *state) { -- cgit v1.2.3