aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-17 13:11:16 +0100
committerMax Kellermann <max@duempel.org>2009-01-17 13:11:16 +0100
commit356526457c49384d6ff5b652aa0f33dc74d23508 (patch)
treeb6fe57ffde36c366e2c6e3e650300b8e3b6126f8 /src/output_thread.c
parente726e2a0042f88d84a167bc955fe9d280db82c90 (diff)
downloadmpd-356526457c49384d6ff5b652aa0f33dc74d23508.tar.gz
mpd-356526457c49384d6ff5b652aa0f33dc74d23508.tar.xz
mpd-356526457c49384d6ff5b652aa0f33dc74d23508.zip
pcm_convert: return PCM buffer from pcm_convert()
Removed yet another superfluous buffer layer: return the PCM buffer from pcm_convert() instead of copying PCM data into the caller-supplied buffer.
Diffstat (limited to 'src/output_thread.c')
-rw-r--r--src/output_thread.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/output_thread.c b/src/output_thread.c
index 3d5fe57d6..66f66e88c 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -38,29 +38,6 @@ static void ao_command_finished(struct audio_output *ao)
notify_signal(&audio_output_client_notify);
}
-static void convertAudioFormat(struct audio_output *audioOutput,
- const char **chunkArgPtr, size_t *sizeArgPtr)
-{
- size_t size = pcm_convert_size(&(audioOutput->inAudioFormat),
- *sizeArgPtr,
- &(audioOutput->outAudioFormat));
-
- if (size > audioOutput->convBufferLen) {
- if (audioOutput->convBuffer != NULL)
- free(audioOutput->convBuffer);
- audioOutput->convBuffer = g_malloc(size);
- audioOutput->convBufferLen = size;
- }
-
- *sizeArgPtr = pcm_convert(&(audioOutput->inAudioFormat),
- *chunkArgPtr, *sizeArgPtr,
- &(audioOutput->outAudioFormat),
- audioOutput->convBuffer,
- &audioOutput->convState);
-
- *chunkArgPtr = audioOutput->convBuffer;
-}
-
static void ao_play(struct audio_output *ao)
{
const char *data = ao->args.play.data;
@@ -70,13 +47,15 @@ static void ao_play(struct audio_output *ao)
assert(size > 0);
if (!audio_format_equals(&ao->inAudioFormat, &ao->outAudioFormat)) {
- convertAudioFormat(ao, &data, &size);
+ data = pcm_convert(&ao->convState,
+ &ao->inAudioFormat, data, size,
+ &ao->outAudioFormat, &size);
/* under certain circumstances, pcm_convert() may
return an empty buffer - this condition should be
investigated further, but for now, do this check as
a workaround: */
- if (size == 0)
+ if (data == NULL)
return;
}