mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48: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()
|
p.cond.Signal()
|
||||||
})
|
})
|
||||||
runLoop = true
|
runLoop = true
|
||||||
|
}
|
||||||
|
|
||||||
// Fill the first part before playing to reduce noises (#1632).
|
buf := make([]byte, p.context.maxBufferSize())
|
||||||
buf := make([]byte, p.context.oneBufferSize())
|
for p.p.UnplayedBufferSize() < int64(p.context.maxBufferSize()) {
|
||||||
n, err := p.src.Read(buf)
|
n, err := p.src.Read(buf)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
p.setErrorImpl(err)
|
p.setErrorImpl(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.p.AppendBuffer(buf[:n])
|
p.p.AppendBuffer(buf[:n])
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.p.Play(); err != nil {
|
if err := p.p.Play(); err != nil {
|
||||||
p.setErrorImpl(err)
|
p.setErrorImpl(err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user