audio: Bug fix: Reduce delay for desktops

This commit is contained in:
Hajime Hoshi 2015-01-26 01:58:21 +09:00
parent 7692cf6a1b
commit 205c6f1462

View File

@ -62,7 +62,7 @@ func initialize() {
emptyBytes := make([]byte, 4*bufferSize) emptyBytes := make([]byte, 4*bufferSize)
for _, source := range sources { for _, source := range sources {
const bufferNum = 16 const bufferNum = 4
buffers := openal.NewBuffers(bufferNum) buffers := openal.NewBuffers(bufferNum)
for _, buffer := range buffers { for _, buffer := range buffers {
buffer.SetData(openal.FormatStereo16, emptyBytes, SampleRate) buffer.SetData(openal.FormatStereo16, emptyBytes, SampleRate)
@ -81,6 +81,7 @@ func initialize() {
if processed == 0 { if processed == 0 {
continue continue
} }
oneProcessed = true oneProcessed = true
buffers := make([]openal.Buffer, processed) buffers := make([]openal.Buffer, processed)
source.UnqueueBuffers(buffers) source.UnqueueBuffers(buffers)
@ -90,6 +91,10 @@ func initialize() {
buffer.SetData(openal.FormatStereo16, b, SampleRate) buffer.SetData(openal.FormatStereo16, b, SampleRate)
source.QueueBuffer(buffer) source.QueueBuffer(buffer)
} }
if source.State() == openal.Stopped {
source.Rewind()
source.Play()
}
} }
if !oneProcessed { if !oneProcessed {
time.Sleep(1) time.Sleep(1)