aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder_api.c2
-rw-r--r--src/output_init.c2
-rw-r--r--src/pcm_utils.c5
-rw-r--r--src/pcm_utils.h2
4 files changed, 9 insertions, 2 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index a90fb6370..f20dbf42d 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -47,7 +47,7 @@ void decoder_initialized(struct decoder * decoder,
{
assert(dc.state == DECODE_STATE_START);
- memset(&decoder->conv_state, 0, sizeof(decoder->conv_state));
+ pcm_convert_init(&decoder->conv_state);
if (audio_format != NULL) {
dc.audioFormat = *audio_format;
diff --git a/src/output_init.c b/src/output_init.c
index cf50db3ad..ebfbf137e 100644
--- a/src/output_init.c
+++ b/src/output_init.c
@@ -90,7 +90,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
ao->convBuffer = NULL;
ao->convBufferLen = 0;
- memset(&ao->convState, 0, sizeof(ao->convState));
+ pcm_convert_init(&ao->convState);
if (format) {
if (0 != parseAudioConfig(&ao->reqAudioFormat, format)) {
diff --git a/src/pcm_utils.c b/src/pcm_utils.c
index 29932ba4b..5d315bdb3 100644
--- a/src/pcm_utils.c
+++ b/src/pcm_utils.c
@@ -205,6 +205,11 @@ void pcm_mix(char *buffer1, const char *buffer2, size_t size,
pcm_add(buffer1, buffer2, size, vol1, 1000 - vol1, format);
}
+void pcm_convert_init(struct pcm_convert_state *state)
+{
+ memset(state, 0, sizeof(*state));
+}
+
#ifdef HAVE_LIBSAMPLERATE
static int pcm_resample_get_converter(void)
{
diff --git a/src/pcm_utils.h b/src/pcm_utils.h
index b67fae00e..3fc15e8b7 100644
--- a/src/pcm_utils.h
+++ b/src/pcm_utils.h
@@ -51,6 +51,8 @@ void pcm_volume(char *buffer, int bufferSize,
void pcm_mix(char *buffer1, const char *buffer2, size_t size,
const struct audio_format *format, float portion1);
+void pcm_convert_init(struct pcm_convert_state *state);
+
size_t pcm_convert(const struct audio_format *inFormat,
const char *inBuffer, size_t inSize,
const struct audio_format *outFormat,