From 25665f503573a131f8aade180f1a1c8d3bb25572 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 6 Apr 2016 03:31:06 +0900 Subject: [PATCH] audio: No need for loop in audio_openal; alSource's state might be al.Initial --- exp/audio/audio_openal.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/exp/audio/audio_openal.go b/exp/audio/audio_openal.go index 6af49b204..7363d3097 100644 --- a/exp/audio/audio_openal.go +++ b/exp/audio/audio_openal.go @@ -87,7 +87,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] @@ -101,12 +101,9 @@ func (p *player) proceed() error { if err != nil { return err } - if n == 0 { - time.Sleep(1 * time.Millisecond) - } } - if p.alSource.State() == al.Stopped { + if p.alSource.State() == al.Stopped || p.alSource.State() == al.Initial { al.RewindSources(p.alSource) al.PlaySources(p.alSource) if err := al.Error(); err != 0 {