output/Thread: wake up the player thread periodically while playing
Without this, the pipe would run empty very often, which may result in an xrun if the roundtrip to the PlayerThread and back takes too long. By waking up the PlayerThread before the pipe runs empty, we make MPD much more latency tolerant, which is a major optimization.
This commit is contained in:
@@ -493,10 +493,21 @@ AudioOutput::Play()
|
||||
in_playback_loop = false;
|
||||
};
|
||||
|
||||
unsigned n = 0;
|
||||
|
||||
do {
|
||||
if (command != Command::NONE)
|
||||
return true;
|
||||
|
||||
if (++n >= 64) {
|
||||
/* wake up the player every now and then to
|
||||
give it a chance to refill the pipe before
|
||||
it runs empty */
|
||||
const ScopeUnlock unlock(mutex);
|
||||
player_control->LockSignal();
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if (!PlayChunk(chunk))
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user