From 975143ab474a020723f333e2dd7bb064038623d4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 29 Oct 2009 22:39:42 +0100 Subject: output_control: fixed deadlock in audio_output_update() Call a version of audio_output_close() which doesn't lock recursively. --- src/output_control.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/output_control.c b/src/output_control.c index 46d8f8696..973baa463 100644 --- a/src/output_control.c +++ b/src/output_control.c @@ -157,6 +157,26 @@ audio_output_open(struct audio_output *ao, return open; } +/** + * Same as audio_output_close(), but expects the lock to be held by + * the caller. + */ +static void +audio_output_close_locked(struct audio_output *ao) +{ + if (ao->mixer != NULL) + mixer_auto_close(ao->mixer); + + assert(!ao->open || ao->fail_timer == NULL); + + if (ao->open) + ao_command(ao, AO_COMMAND_CLOSE); + else if (ao->fail_timer != NULL) { + g_timer_destroy(ao->fail_timer); + ao->fail_timer = NULL; + } +} + bool audio_output_update(struct audio_output *ao, const struct audio_format *audio_format, @@ -174,7 +194,7 @@ audio_output_update(struct audio_output *ao, return success; } } else if (audio_output_is_open(ao)) - audio_output_close(ao); + audio_output_close_locked(ao); g_mutex_unlock(ao->mutex); return false; -- cgit v1.2.3