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
}
buf := make([]byte, p.context.maxBufferSize())
for len(p.buf) < p.context.maxBufferSize() {
n, err := p.src.Read(buf)
if err != nil && err != io.EOF {
p.setErrorImpl(err)
return
}
p.buf = append(p.buf, buf[:n]...)
if err == io.EOF {
break
if !p.eof {
buf := make([]byte, p.context.maxBufferSize())
for len(p.buf) < p.context.maxBufferSize() {
n, err := p.src.Read(buf)
if err != nil && err != io.EOF {
p.setErrorImpl(err)
return
}
p.buf = append(p.buf, buf[:n]...)
if err == io.EOF {
if len(p.buf) == 0 {
p.eof = true
}
break
}
}
}