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.
This commit is contained in:
Max Kellermann
2009-03-25 17:07:15 +01:00
parent 71cd24954a
commit 4dbf73d88b
3 changed files with 33 additions and 15 deletions

View File

@@ -65,6 +65,11 @@ struct audio_output {
/**
* Is the device (already) open and functional?
*
* This attribute may only be modified by the output thread.
* It is protected with #mutex: write accesses inside the
* output thread and read accesses outside of it may only be
* performed while the lock is held.
*/
bool open;
@@ -113,7 +118,7 @@ struct audio_output {
const struct music_pipe *pipe;
/**
* This mutex protects #chunk and #chunk_finished.
* This mutex protects #open, #chunk and #chunk_finished.
*/
GMutex *mutex;