From bd8ecba4495d0de223e07a0a22600c8da03a2211 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Feb 2009 22:07:59 +0100 Subject: output_thread: consistently (de)initialize pcm_convert_state Fix a memory leak: it was not guaranteed that pcm_convert_deinit() was called for each pcm_convert_init(). This patch always (de)initializes the pcm_convert library when the audio_output.open flag is flipped. --- src/output_thread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/output_thread.c b/src/output_thread.c index ef636180f..257261415 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -91,6 +91,7 @@ static void ao_pause(struct audio_output *ao) } else { /* pause is not supported - simply close the device */ ao->plugin->close(ao->data); + pcm_convert_deinit(&ao->convert_state); ao->open = false; ao_command_finished(ao); } @@ -109,14 +110,14 @@ static gpointer audio_output_task(gpointer arg) case AO_COMMAND_OPEN: assert(!ao->open); - pcm_convert_init(&ao->convert_state); ret = ao->plugin->open(ao->data, &ao->out_audio_format); assert(!ao->open); - if (ret == true) + if (ret) { + pcm_convert_init(&ao->convert_state); ao->open = true; - else + } else ao->reopen_after = time(NULL) + REOPEN_AFTER; ao_command_finished(ao); @@ -127,6 +128,7 @@ static gpointer audio_output_task(gpointer arg) ao->plugin->cancel(ao->data); ao->plugin->close(ao->data); + pcm_convert_deinit(&ao->convert_state); ao->open = false; ao_command_finished(ao); break; -- cgit v1.2.3