output/MultipleOutputs: simplify locking in CheckPipe()

Instead of keeping all open outputs locked, let ClearTailChunk() stall
playback until MultipleOutputs::CheckPipe() has updated the MusicPipe.
This commit is contained in:
Max Kellermann
2019-04-26 18:12:27 +02:00
parent ec456fc57c
commit 684bd9153e
3 changed files with 27 additions and 38 deletions
+21
View File
@@ -404,8 +404,29 @@ public:
gcc_pure
bool LockIsChunkConsumed(const MusicChunk &chunk) const noexcept;
/**
* There's only one chunk left in the pipe (#pipe), and all
* audio outputs have consumed it already. Clear the
* reference.
*
* This stalls playback to give the caller a chance to shift
* the #MusicPipe without getting disturbed; after this,
* LockAllowPlay() must be called to resume playback.
*/
void ClearTailChunk(const MusicChunk &chunk) noexcept {
if (!IsOpen())
return;
source.ClearTailChunk(chunk);
allow_play = false;
}
/**
* Locking wrapper for ClearTailChunk().
*/
void LockClearTailChunk(const MusicChunk &chunk) noexcept {
const std::lock_guard<Mutex> lock(mutex);
ClearTailChunk(chunk);
}
void LockPlay() noexcept;