audio: Refactoring: Add loop

This commit is contained in:
Hajime Hoshi 2016-05-26 03:15:51 +09:00
parent d6dee0815e
commit ca2f85f3d1

View File

@ -219,7 +219,11 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
}); err != nil { }); err != nil {
return nil, err return nil, err
} }
go func() { go p.loop()
return p, nil
}
func (p *Player) loop() {
for bufInBytes := range p.chBuffer { for bufInBytes := range p.chBuffer {
var bufInShorts []int16 var bufInShorts []int16
if p.bytesPerSample == 2 { if p.bytesPerSample == 2 {
@ -250,8 +254,6 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
return return
} }
} }
}()
return p, nil
} }
func (p *Player) Proceed(data []byte) error { func (p *Player) Proceed(data []byte) error {