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:
parent
61e3075981
commit
bd8ecba449
@ -91,6 +91,7 @@ static void ao_pause(struct audio_output *ao)
|
|||||||
} else {
|
} else {
|
||||||
/* pause is not supported - simply close the device */
|
/* pause is not supported - simply close the device */
|
||||||
ao->plugin->close(ao->data);
|
ao->plugin->close(ao->data);
|
||||||
|
pcm_convert_deinit(&ao->convert_state);
|
||||||
ao->open = false;
|
ao->open = false;
|
||||||
ao_command_finished(ao);
|
ao_command_finished(ao);
|
||||||
}
|
}
|
||||||
@ -109,14 +110,14 @@ static gpointer audio_output_task(gpointer arg)
|
|||||||
case AO_COMMAND_OPEN:
|
case AO_COMMAND_OPEN:
|
||||||
assert(!ao->open);
|
assert(!ao->open);
|
||||||
|
|
||||||
pcm_convert_init(&ao->convert_state);
|
|
||||||
ret = ao->plugin->open(ao->data,
|
ret = ao->plugin->open(ao->data,
|
||||||
&ao->out_audio_format);
|
&ao->out_audio_format);
|
||||||
|
|
||||||
assert(!ao->open);
|
assert(!ao->open);
|
||||||
if (ret == true)
|
if (ret) {
|
||||||
|
pcm_convert_init(&ao->convert_state);
|
||||||
ao->open = true;
|
ao->open = true;
|
||||||
else
|
} else
|
||||||
ao->reopen_after = time(NULL) + REOPEN_AFTER;
|
ao->reopen_after = time(NULL) + REOPEN_AFTER;
|
||||||
|
|
||||||
ao_command_finished(ao);
|
ao_command_finished(ao);
|
||||||
@ -127,6 +128,7 @@ static gpointer audio_output_task(gpointer arg)
|
|||||||
ao->plugin->cancel(ao->data);
|
ao->plugin->cancel(ao->data);
|
||||||
ao->plugin->close(ao->data);
|
ao->plugin->close(ao->data);
|
||||||
|
|
||||||
|
pcm_convert_deinit(&ao->convert_state);
|
||||||
ao->open = false;
|
ao->open = false;
|
||||||
ao_command_finished(ao);
|
ao_command_finished(ao);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user