Change sleeping time

This commit is contained in:
Hajime Hoshi 2015-06-07 22:01:14 +09:00
parent ab5a598d27
commit 47f31f75a0
2 changed files with 5 additions and 5 deletions

View File

@ -81,7 +81,6 @@ func Play(channel int, l []int16, r []int16) bool {
ch.l = append(ch.l, l...)
ch.r = append(ch.r, r...)
result = true
return
})
return result
}

View File

@ -20,11 +20,12 @@ import (
"bytes"
"encoding/binary"
"fmt"
"github.com/timshannon/go-openal/openal"
"log"
"runtime"
"sync"
"time"
"github.com/timshannon/go-openal/openal"
)
var channelsMutex = sync.Mutex{}
@ -94,7 +95,7 @@ func initialize() {
for {
oneProcessed := false
for channel, source := range sources {
for ch, source := range sources {
processed := source.BuffersProcessed()
if processed == 0 {
continue
@ -104,7 +105,7 @@ func initialize() {
buffers := make([]openal.Buffer, processed)
source.UnqueueBuffers(buffers)
for _, buffer := range buffers {
l, r := loadChannelBuffer(channel, bufferSize)
l, r := loadChannelBuffer(ch, bufferSize)
b := toBytesWithPadding(l, r, bufferSize)
buffer.SetData(openal.FormatStereo16, b, SampleRate)
source.QueueBuffer(buffer)
@ -115,7 +116,7 @@ func initialize() {
}
}
if !oneProcessed {
time.Sleep(1)
time.Sleep(1 * time.Millisecond)
}
}
}()