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.
This commit is contained in:
Max Kellermann 2009-02-10 22:07:59 +01:00
parent 61e3075981
commit bd8ecba449

View File

@ -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;