mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
audio/internal/readerdriver: Fill the buffer whenever starting to play
This commit is contained in:
parent
ae9e89b814
commit
fcdd4e16d4
@ -110,16 +110,21 @@ func (p *player) Play() {
|
||||
p.cond.Signal()
|
||||
})
|
||||
runLoop = true
|
||||
}
|
||||
|
||||
// Fill the first part before playing to reduce noises (#1632).
|
||||
buf := make([]byte, p.context.oneBufferSize())
|
||||
buf := make([]byte, p.context.maxBufferSize())
|
||||
for p.p.UnplayedBufferSize() < int64(p.context.maxBufferSize()) {
|
||||
n, err := p.src.Read(buf)
|
||||
if err != nil && err != io.EOF {
|
||||
p.setErrorImpl(err)
|
||||
return
|
||||
}
|
||||
p.p.AppendBuffer(buf[:n])
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if err := p.p.Play(); err != nil {
|
||||
p.setErrorImpl(err)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user