From 205c6f14629c522ba0aaf15b42cb585edf4e2a6f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 26 Jan 2015 01:58:21 +0900 Subject: [PATCH] audio: Bug fix: Reduce delay for desktops --- internal/audio/audio_openal.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/audio/audio_openal.go b/internal/audio/audio_openal.go index b7a53b026..5c2b3fd01 100644 --- a/internal/audio/audio_openal.go +++ b/internal/audio/audio_openal.go @@ -62,7 +62,7 @@ func initialize() { emptyBytes := make([]byte, 4*bufferSize) for _, source := range sources { - const bufferNum = 16 + const bufferNum = 4 buffers := openal.NewBuffers(bufferNum) for _, buffer := range buffers { buffer.SetData(openal.FormatStereo16, emptyBytes, SampleRate) @@ -81,6 +81,7 @@ func initialize() { if processed == 0 { continue } + oneProcessed = true buffers := make([]openal.Buffer, processed) source.UnqueueBuffers(buffers) @@ -90,6 +91,10 @@ func initialize() { buffer.SetData(openal.FormatStereo16, b, SampleRate) source.QueueBuffer(buffer) } + if source.State() == openal.Stopped { + source.Rewind() + source.Play() + } } if !oneProcessed { time.Sleep(1)