audio: Make sure to fill 4096 bytes

This commit is contained in:
Hajime Hoshi 2016-03-06 03:48:47 +09:00
parent e69b44e327
commit c090805021

View File

@ -89,6 +89,8 @@ func (p *player) proceed() error {
p.position = c
}
b := make([]byte, bufferSize)
for 0 < len(b) {
print(len(b))
n, err := p.src.Read(b)
if 0 < n {
const channelNum = 2
@ -107,9 +109,14 @@ func (p *player) proceed() error {
p.bufferSource.Call("connect", p.context.Get("destination"))
p.bufferSource.Call("start", maxF(p.position, c))
p.position += buf.Get("duration").Float()
b = b[n:]
}
if err != nil {
return err
}
}
return nil
}
func (p *player) start() error {
// TODO: What if play is already called?