From 7692cf6a1b57a77ba507322e6279b289a5d289e1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 26 Jan 2015 01:39:43 +0900 Subject: [PATCH] audio: Refactoring --- internal/audio/audio.go | 26 -------------------------- internal/audio/audio_openal.go | 9 +-------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/internal/audio/audio.go b/internal/audio/audio.go index 59083f4ff..eb3e891d9 100644 --- a/internal/audio/audio.go +++ b/internal/audio/audio.go @@ -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() diff --git a/internal/audio/audio_openal.go b/internal/audio/audio_openal.go index a6150bc5e..b7a53b026 100644 --- a/internal/audio/audio_openal.go +++ b/internal/audio/audio_openal.go @@ -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