Commit 1d00d55d authored by Max Kellermann's avatar Max Kellermann

player/Thread: stop buffering if buffer is full

Shouldn't ever happen, but who knows...
parent a190db08
......@@ -29,7 +29,7 @@
*/
class MusicBuffer {
/** a mutex which protects #buffer */
Mutex mutex;
mutable Mutex mutex;
SliceBuffer<MusicChunk> buffer;
......@@ -53,6 +53,11 @@ public:
}
#endif
bool IsFull() const noexcept {
const std::lock_guard<Mutex> protect(mutex);
return buffer.IsFull();
}
/**
* Returns the total number of reserved chunks in this buffer. This
* is the same value which was passed to the constructor
......
......@@ -944,7 +944,7 @@ Player::Run() noexcept
prevent stuttering on slow machines */
if (pipe->GetSize() < pc.buffered_before_play &&
!dc.IsIdle()) {
!dc.IsIdle() && !buffer.IsFull()) {
/* not enough decoded buffer space yet */
dc.WaitForDecoder();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment