aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-25 17:07:15 +0100
committerMax Kellermann <max@duempel.org>2009-03-25 17:07:15 +0100
commit4dbf73d88bf5ab2da154ac2f537aa28a67c5f8b6 (patch)
tree56158acb8882f2879af37ed4345dc571c272150c /src/output_thread.c
parent71cd24954a34bc9fb0fdf6505616ba79b8320a5a (diff)
downloadmpd-4dbf73d88bf5ab2da154ac2f537aa28a67c5f8b6.tar.gz
mpd-4dbf73d88bf5ab2da154ac2f537aa28a67c5f8b6.tar.xz
mpd-4dbf73d88bf5ab2da154ac2f537aa28a67c5f8b6.zip
output: protect audio_output.open with the mutex
There was a deadlock between the output thread and the player thread: when the output thread failed (and closed itself) while the player thread worked with the audio_output object, MPD could crash.
Diffstat (limited to '')
-rw-r--r--src/output_thread.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/output_thread.c b/src/output_thread.c
index b9325c073..62b893074 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -48,11 +48,11 @@ ao_close(struct audio_output *ao)
g_mutex_lock(ao->mutex);
ao->chunk = NULL;
+ ao->open = false;
g_mutex_unlock(ao->mutex);
ao_plugin_close(ao->plugin, ao->data);
pcm_convert_deinit(&ao->convert_state);
- ao->open = false;
g_debug("closed plugin=%s name=\"%s\"", ao->plugin->name, ao->name);
}
@@ -198,8 +198,10 @@ static gpointer audio_output_task(gpointer arg)
assert(!ao->open);
if (ret) {
pcm_convert_init(&ao->convert_state);
- ao->open = true;
+ g_mutex_lock(ao->mutex);
+ ao->open = true;
+ g_mutex_unlock(ao->mutex);
g_debug("opened plugin=%s name=\"%s\" "
"audio_format=%u:%u:%u",