player/Thread: stop buffering if buffer is full
Shouldn't ever happen, but who knows...
This commit is contained in:
parent
a190db0873
commit
1d00d55d53
@ -29,7 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
class MusicBuffer {
|
class MusicBuffer {
|
||||||
/** a mutex which protects #buffer */
|
/** a mutex which protects #buffer */
|
||||||
Mutex mutex;
|
mutable Mutex mutex;
|
||||||
|
|
||||||
SliceBuffer<MusicChunk> buffer;
|
SliceBuffer<MusicChunk> buffer;
|
||||||
|
|
||||||
@ -53,6 +53,11 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
* Returns the total number of reserved chunks in this buffer. This
|
||||||
* is the same value which was passed to the constructor
|
* is the same value which was passed to the constructor
|
||||||
|
@ -944,7 +944,7 @@ Player::Run() noexcept
|
|||||||
prevent stuttering on slow machines */
|
prevent stuttering on slow machines */
|
||||||
|
|
||||||
if (pipe->GetSize() < pc.buffered_before_play &&
|
if (pipe->GetSize() < pc.buffered_before_play &&
|
||||||
!dc.IsIdle()) {
|
!dc.IsIdle() && !buffer.IsFull()) {
|
||||||
/* not enough decoded buffer space yet */
|
/* not enough decoded buffer space yet */
|
||||||
|
|
||||||
dc.WaitForDecoder();
|
dc.WaitForDecoder();
|
||||||
|
Loading…
Reference in New Issue
Block a user