mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
audio: Refactoring
This commit is contained in:
parent
9e7dfa2f16
commit
7692cf6a1b
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user