aboutsummaryrefslogtreecommitdiffstats
path: root/src/DecoderControl.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-11-06 23:10:05 +0100
committerMax Kellermann <max@duempel.org>2013-11-06 23:51:17 +0100
commit0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee (patch)
tree0e1a98376069ab299dbd701d7be40f8030da70f8 /src/DecoderControl.cxx
parent9802e74859219ae151cddb238f71016e3a2ef1ef (diff)
downloadmpd-0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee.tar.gz
mpd-0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee.tar.xz
mpd-0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee.zip
DecoderControl: reduce the number of PlayerThread wakeups
Wake up the PlayerThread only if it is really waiting for the decoder. This greatly reduces the number of system calls in the DecoderThread.
Diffstat (limited to '')
-rw-r--r--src/DecoderControl.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/DecoderControl.cxx b/src/DecoderControl.cxx
index d76580cbb..ab460ced0 100644
--- a/src/DecoderControl.cxx
+++ b/src/DecoderControl.cxx
@@ -30,6 +30,7 @@ DecoderControl::DecoderControl(Mutex &_mutex, Cond &_client_cond)
:mutex(_mutex), client_cond(_client_cond),
state(DecoderState::STOP),
command(DecoderCommand::NONE),
+ client_is_waiting(false),
song(nullptr),
replay_gain_db(0), replay_gain_prev_db(0) {}
@@ -41,6 +42,18 @@ DecoderControl::~DecoderControl()
song->Free();
}
+void
+DecoderControl::WaitForDecoder()
+{
+ assert(!client_is_waiting);
+ client_is_waiting = true;
+
+ client_cond.wait(mutex);
+
+ assert(client_is_waiting);
+ client_is_waiting = false;
+}
+
bool
DecoderControl::IsCurrentSong(const Song &_song) const
{