From 2d3c3e361eab0c834dfbee7776a99f2dea6e6937 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 5 Apr 2016 03:31:37 +0900 Subject: [PATCH] audio: Replace 'for' with 'if' as preparation to avoid goroutine --- exp/audio/audio_openal.go | 3 +-- exp/audio/audio_windows.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exp/audio/audio_openal.go b/exp/audio/audio_openal.go index ddef418d5..614e859ae 100644 --- a/exp/audio/audio_openal.go +++ b/exp/audio/audio_openal.go @@ -100,7 +100,7 @@ func (p *player) proceed() error { p.alBuffers = append(p.alBuffers, bufs...) } - for 0 < len(p.alBuffers) { + if 0 < len(p.alBuffers) { n, err := p.source.Read(tmpBuffer) if 0 < n { buf := p.alBuffers[0] @@ -130,7 +130,6 @@ func (p *player) proceed() error { return nil } -// TODO: When is this called? Can we remove this? func (p *player) close() error { if err := al.Error(); err != 0 { return fmt.Errorf("audio: error before closing: %d", err) diff --git a/exp/audio/audio_windows.go b/exp/audio/audio_windows.go index d28c70373..fd15c2aae 100644 --- a/exp/audio/audio_windows.go +++ b/exp/audio/audio_windows.go @@ -116,6 +116,7 @@ func newPlayer(src io.Reader, sampleRate int) (*player, error) { } func (p *player) proceed() error { + // TODO: Read should be called only when there are buffers available? b := make([]byte, bufferSize) n, err := p.src.Read(b) if 0 < n {