audio: No need for loop in audio_openal; alSource's state might be al.Initial

This commit is contained in:
Hajime Hoshi 2016-04-06 03:31:06 +09:00
parent 1ded7dc6b8
commit 25665f5035

View File

@ -87,7 +87,7 @@ func (p *player) proceed() error {
p.alBuffers = append(p.alBuffers, bufs...) p.alBuffers = append(p.alBuffers, bufs...)
} }
for 0 < len(p.alBuffers) { if 0 < len(p.alBuffers) {
n, err := p.source.Read(tmpBuffer) n, err := p.source.Read(tmpBuffer)
if 0 < n { if 0 < n {
buf := p.alBuffers[0] buf := p.alBuffers[0]
@ -101,12 +101,9 @@ func (p *player) proceed() error {
if err != nil { if err != nil {
return err 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.RewindSources(p.alSource)
al.PlaySources(p.alSource) al.PlaySources(p.alSource)
if err := al.Error(); err != 0 { if err := al.Error(); err != 0 {