aboutsummaryrefslogtreecommitdiffstats
path: root/src/DecoderControl.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-28 10:09:04 +0100
committerMax Kellermann <max@duempel.org>2013-10-28 10:22:05 +0100
commit1ad2475f9e3c88b992f3fd3d6a77842287d3e4db (patch)
treeb9d16a4bfeb2fa54f1bfe002df3da44341929709 /src/DecoderControl.hxx
parent5b5675cc121eff6ba4b89719a523bfbe3993ce2f (diff)
downloadmpd-1ad2475f9e3c88b992f3fd3d6a77842287d3e4db.tar.gz
mpd-1ad2475f9e3c88b992f3fd3d6a77842287d3e4db.tar.xz
mpd-1ad2475f9e3c88b992f3fd3d6a77842287d3e4db.zip
DecoderControl: convert mutex and client_cond to a reference
Share the Mutex between the DecoderThread and the PlayerThread. This simplifies synchronization between the two threads and fixes a freeze problem: while the PlayerThread waits for the DeocderThread, it cannot answer requests from the main thread, and the main thread will block until the DecoderThread finishes.
Diffstat (limited to '')
-rw-r--r--src/DecoderControl.hxx17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/DecoderControl.hxx b/src/DecoderControl.hxx
index 4b3137108..23cb394ca 100644
--- a/src/DecoderControl.hxx
+++ b/src/DecoderControl.hxx
@@ -62,8 +62,13 @@ struct DecoderControl {
/**
* This lock protects #state and #command.
+ *
+ * This is usually a reference to PlayerControl::mutex, so
+ * that both player thread and decoder thread share a mutex.
+ * This simplifies synchronization with #cond and
+ * #client_cond.
*/
- mutable Mutex mutex;
+ Mutex &mutex;
/**
* Trigger this object after you have modified #command. This
@@ -75,8 +80,10 @@ struct DecoderControl {
/**
* The trigger of this object's client. It is signalled
* whenever an event occurs.
+ *
+ * This is usually a reference to PlayerControl::cond.
*/
- Cond client_cond;
+ Cond &client_cond;
DecoderState state;
DecoderCommand command;
@@ -143,7 +150,11 @@ struct DecoderControl {
MixRampInfo mix_ramp, previous_mix_ramp;
- DecoderControl();
+ /**
+ * @param _mutex see #mutex
+ * @param _client_cond see #client_cond
+ */
+ DecoderControl(Mutex &_mutex, Cond &_client_cond);
~DecoderControl();
/**