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 p.position = c
} }
b := make([]byte, bufferSize) b := make([]byte, bufferSize)
for 0 < len(b) {
print(len(b))
n, err := p.src.Read(b) n, err := p.src.Read(b)
if 0 < n { if 0 < n {
const channelNum = 2 const channelNum = 2
@ -107,8 +109,13 @@ func (p *player) proceed() error {
p.bufferSource.Call("connect", p.context.Get("destination")) p.bufferSource.Call("connect", p.context.Get("destination"))
p.bufferSource.Call("start", maxF(p.position, c)) p.bufferSource.Call("start", maxF(p.position, c))
p.position += buf.Get("duration").Float() p.position += buf.Get("duration").Float()
b = b[n:]
} }
if err != nil {
return err return err
}
}
return nil
} }
func (p *player) start() error { func (p *player) start() error {