audio/internal/readerdriver: Bug fix: A player must be the EOF state when the buffer is empty

This commit is contained in:
Hajime Hoshi 2021-06-07 03:20:39 +09:00
parent 9f9d53aad3
commit 658192f83d

View File

@ -172,16 +172,21 @@ func (p *playerImpl) playImpl() {
return return
} }
buf := make([]byte, p.context.maxBufferSize()) if !p.eof {
for len(p.buf) < p.context.maxBufferSize() { buf := make([]byte, p.context.maxBufferSize())
n, err := p.src.Read(buf) for len(p.buf) < p.context.maxBufferSize() {
if err != nil && err != io.EOF { n, err := p.src.Read(buf)
p.setErrorImpl(err) if err != nil && err != io.EOF {
return p.setErrorImpl(err)
} return
p.buf = append(p.buf, buf[:n]...) }
if err == io.EOF { p.buf = append(p.buf, buf[:n]...)
break if err == io.EOF {
if len(p.buf) == 0 {
p.eof = true
}
break
}
} }
} }