audio: Refactoring: Remove unneeded for loop

This commit is contained in:
Hajime Hoshi 2016-03-11 02:09:12 +09:00
parent 7aaa599f6b
commit 1313644611

View File

@ -81,7 +81,6 @@ func (p *player) proceed() error {
p.positionInSamples = c
}
b := make([]byte, bufferSize)
for 0 < len(b) {
n, err := p.src.Read(b)
if 0 < n {
const channelNum = 2
@ -98,17 +97,11 @@ func (p *player) proceed() error {
p.bufferSource = p.context.Call("createBufferSource")
p.bufferSource.Set("buffer", buf)
p.bufferSource.Call("connect", p.context.Get("destination"))
p.bufferSource.Call("start", float64(max64(p.positionInSamples, c))/float64(p.sampleRate))
p.bufferSource.Call("start", float64(p.positionInSamples)/float64(p.sampleRate))
p.positionInSamples += int64(len(il))
b = b[n:]
}
if err != nil {
return err
}
runtime.Gosched()
}
return nil
}
func (p *player) start() error {
// TODO: What if play is already called?