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.
This commit is contained in:
parent
0be5a6ab2b
commit
77c63511d8
|
@ -68,6 +68,12 @@ class Player {
|
||||||
*/
|
*/
|
||||||
bool decoder_starting;
|
bool decoder_starting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Did we wake up the DecoderThread recently? This avoids
|
||||||
|
* duplicate wakeup calls.
|
||||||
|
*/
|
||||||
|
bool decoder_woken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* is the player paused?
|
* is the player paused?
|
||||||
*/
|
*/
|
||||||
|
@ -133,6 +139,7 @@ public:
|
||||||
:pc(_pc), dc(_dc), buffer(_buffer),
|
:pc(_pc), dc(_dc), buffer(_buffer),
|
||||||
buffering(true),
|
buffering(true),
|
||||||
decoder_starting(false),
|
decoder_starting(false),
|
||||||
|
decoder_woken(false),
|
||||||
paused(false),
|
paused(false),
|
||||||
queued(true),
|
queued(true),
|
||||||
output_open(false),
|
output_open(false),
|
||||||
|
@ -861,8 +868,13 @@ Player::PlayNextChunk()
|
||||||
pc.Lock();
|
pc.Lock();
|
||||||
if (!dc.IsIdle() &&
|
if (!dc.IsIdle() &&
|
||||||
dc.pipe->GetSize() <= (pc.buffered_before_play +
|
dc.pipe->GetSize() <= (pc.buffered_before_play +
|
||||||
buffer.GetSize() * 3) / 4)
|
buffer.GetSize() * 3) / 4) {
|
||||||
dc.Signal();
|
if (!decoder_woken) {
|
||||||
|
decoder_woken = true;
|
||||||
|
dc.Signal();
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
decoder_woken = false;
|
||||||
pc.Unlock();
|
pc.Unlock();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue