audio/internal/readerdriver: Bug fix: Avoid busy loop when EOF is reached

This is a part of reverting 81015a3c19.

On Drawin, the loop became busy when the source reached EOF. This
change fixes this issue by making the loop wait when the EOF is
reached and until the state is reset.

Updates #1650
This commit is contained in:
Hajime Hoshi 2021-05-26 03:27:17 +09:00
parent 95a98950b8
commit 91d3d6b4e7

View File

@ -621,7 +621,9 @@ func (p *playerImpl) shouldWait() bool {
case playerPaused: case playerPaused:
return true return true
case playerPlay: case playerPlay:
return len(p.buf) >= p.context.maxBufferSize() // If the buffer has too much data, wait until the buffer data is consumed.
// If the source reaches EOF, wait until the state is reset.
return len(p.buf) >= p.context.maxBufferSize() || p.eof
case playerClosed: case playerClosed:
return false return false
default: default: