diff options
Diffstat (limited to '')
-rw-r--r-- | src/output_control.c | 2 | ||||
-rw-r--r-- | src/output_init.c | 3 | ||||
-rw-r--r-- | src/output_internal.h | 2 | ||||
-rw-r--r-- | src/output_thread.c | 29 |
4 files changed, 4 insertions, 32 deletions
diff --git a/src/output_control.c b/src/output_control.c index 503001470..db3ab5622 100644 --- a/src/output_control.c +++ b/src/output_control.c @@ -142,8 +142,6 @@ void audio_output_finish(struct audio_output *audioOutput) if (audioOutput->plugin->finish) audioOutput->plugin->finish(audioOutput->data); - if (audioOutput->convBuffer) - free(audioOutput->convBuffer); notify_deinit(&audioOutput->notify); } diff --git a/src/output_init.c b/src/output_init.c index 8423e4bbb..bf92cc852 100644 --- a/src/output_init.c +++ b/src/output_init.c @@ -90,9 +90,6 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param) ao->open = false; ao->reopen_after = 0; - ao->convBuffer = NULL; - ao->convBufferLen = 0; - pcm_convert_init(&ao->convState); if (format) { diff --git a/src/output_internal.h b/src/output_internal.h index 17209dd5a..dc363a6b9 100644 --- a/src/output_internal.h +++ b/src/output_internal.h @@ -79,8 +79,6 @@ struct audio_output { struct audio_format reqAudioFormat; struct pcm_convert_state convState; - char *convBuffer; - size_t convBufferLen; /** * The thread handle, or NULL if the output thread isn't 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; } |