audio: Refactoring

This commit is contained in:
Hajime Hoshi 2015-01-26 01:39:43 +09:00
parent 9e7dfa2f16
commit 7692cf6a1b
2 changed files with 1 additions and 34 deletions

View File

@ -164,32 +164,6 @@ func loadChannelBuffer(channel int) (l, r []int16) {
return inputL, inputR
}
/*func loadChannelBuffers() (l, r []int16) {
channelsLock.Lock()
defer channelsLock.Unlock()
if !audioEnabled {
return nil, nil
}
inputL := make([]int16, bufferSize)
inputR := make([]int16, bufferSize)
for _, ch := range channels {
if len(ch.l) == 0 {
continue
}
l := min(len(ch.l), bufferSize)
for i := 0; i < l; i++ {
inputL[i] += ch.l[i]
inputR[i] += ch.r[i]
}
usedLen := min(bufferSize, len(ch.l))
ch.l = ch.l[usedLen:]
ch.r = ch.r[usedLen:]
}
return inputL, inputR
}*/
func IsPlaying(channel int) bool {
channelsLock.Lock()
defer channelsLock.Unlock()

View File

@ -39,11 +39,6 @@ func toBytes(l, r []int16) []byte {
return b.Bytes()
}
type sample struct {
l []float32
r []float32
}
func initialize() {
ch := make(chan struct{})
go func() {
@ -56,6 +51,7 @@ func initialize() {
if alErr := openal.GetError(); alErr != 0 {
log.Printf("OpenAL initialize error: %d", alErr)
close(ch)
// Graceful ending: Audio is not available on Travis CI.
return
}
@ -81,9 +77,6 @@ func initialize() {
for {
oneProcessed := false
for channel, source := range sources {
if source.State() != openal.Playing {
panic(fmt.Sprintf("invalid source state: %d (0x%[1]x)", source.State()))
}
processed := source.BuffersProcessed()
if processed == 0 {
continue