audio: Use io.CopyN

This commit is contained in:
Hajime Hoshi 2017-12-24 21:21:15 +09:00
parent a74cf21f21
commit 5679103d71

View File

@ -259,14 +259,8 @@ func (c *Context) loop() {
c.pingCount-- c.pingCount--
c.m.Unlock() c.m.Unlock()
buf := make([]byte, 4096) const n = 4096
n, err := c.players.Read(buf) if _, err = io.CopyN(p, c.players, n); err != nil {
if err != nil {
audiobinding.SetError(err)
return
}
if _, err = p.Write(buf[:n]); err != nil {
audiobinding.SetError(err) audiobinding.SetError(err)
return return
} }