aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-10 22:07:59 +0100
committerMax Kellermann <max@duempel.org>2009-02-10 22:07:59 +0100
commitbd8ecba4495d0de223e07a0a22600c8da03a2211 (patch)
tree311352c3711e7a872f40c0c05b46fe2623d51296 /src/output_thread.c
parent61e30759812e6996eb02bacf58607ec53cb0f577 (diff)
downloadmpd-bd8ecba4495d0de223e07a0a22600c8da03a2211.tar.gz
mpd-bd8ecba4495d0de223e07a0a22600c8da03a2211.tar.xz
mpd-bd8ecba4495d0de223e07a0a22600c8da03a2211.zip
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.
Diffstat (limited to '')
-rw-r--r--src/output_thread.c8
1 files 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;