aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-11-06 23:30:29 +0100
committerMax Kellermann <max@duempel.org>2013-11-06 23:51:17 +0100
commit77c63511d8809f7785328138e7e3a50303302730 (patch)
tree6743b89744cb41f36de56a526143b3cbb9c7eb6f /src
parent0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee (diff)
downloadmpd-77c63511d8809f7785328138e7e3a50303302730.tar.gz
mpd-77c63511d8809f7785328138e7e3a50303302730.tar.xz
mpd-77c63511d8809f7785328138e7e3a50303302730.zip
PlayerThread: reduce the number of DecoderThread wakeups
After the number of decoded chunks has fallen below the threshold, the PlayerThread woke up the DecoderThread over and over. This commit adds a boolean flag that avoids these duplicate wakeups, and thus reduces the number of system calls.
Diffstat (limited to 'src')
-rw-r--r--src/PlayerThread.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx
index e2e3ee3a4..cb3d6a9a4 100644
--- a/src/PlayerThread.cxx
+++ b/src/PlayerThread.cxx
@@ -69,6 +69,12 @@ class Player {
bool decoder_starting;
/**
+ * Did we wake up the DecoderThread recently? This avoids
+ * duplicate wakeup calls.
+ */
+ bool decoder_woken;
+
+ /**
* is the player paused?
*/
bool paused;
@@ -133,6 +139,7 @@ public:
:pc(_pc), dc(_dc), buffer(_buffer),
buffering(true),
decoder_starting(false),
+ decoder_woken(false),
paused(false),
queued(true),
output_open(false),
@@ -861,8 +868,13 @@ Player::PlayNextChunk()
pc.Lock();
if (!dc.IsIdle() &&
dc.pipe->GetSize() <= (pc.buffered_before_play +
- buffer.GetSize() * 3) / 4)
- dc.Signal();
+ buffer.GetSize() * 3) / 4) {
+ if (!decoder_woken) {
+ decoder_woken = true;
+ dc.Signal();
+ }
+ } else
+ decoder_woken = false;
pc.Unlock();
return true;