mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
audio: Remove audio.Tick
This commit is contained in:
parent
c5de32297f
commit
719e5ba6d2
@ -59,10 +59,6 @@ func emptyChannel() *channel {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Tick() {
|
||||
tick()
|
||||
}
|
||||
|
||||
// TODO: Accept sample rate
|
||||
func Queue(data []byte) bool {
|
||||
result := true
|
||||
@ -121,14 +117,3 @@ func loadChannelBuffer(channel int, bufferSize int) []byte {
|
||||
})
|
||||
return r
|
||||
}
|
||||
|
||||
func IsPlaying(channel int) bool {
|
||||
result := false
|
||||
withChannels(func() {
|
||||
if !audioEnabled {
|
||||
return
|
||||
}
|
||||
result = isPlaying(channel)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
package audio
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
)
|
||||
|
||||
@ -73,18 +75,6 @@ func isPlaying(channel int) bool {
|
||||
return c < a.position
|
||||
}
|
||||
|
||||
func tick() {
|
||||
const bufferSize = 1024
|
||||
c := context.Get("currentTime").Float()
|
||||
for _, a := range audioProcessors {
|
||||
if a.position < c {
|
||||
a.position = c
|
||||
}
|
||||
// TODO: 4 is a magic number
|
||||
a.playChunk(loadChannelBuffer(a.channel, bufferSize*4))
|
||||
}
|
||||
}
|
||||
|
||||
func initialize() {
|
||||
// Do nothing in node.js.
|
||||
if js.Global.Get("require") != js.Undefined {
|
||||
@ -107,4 +97,18 @@ func initialize() {
|
||||
position: 0,
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
const bufferSize = 1024
|
||||
c := context.Get("currentTime").Float()
|
||||
for _, a := range audioProcessors {
|
||||
if a.position < c {
|
||||
a.position = c
|
||||
}
|
||||
// TODO: 4 is a magic number
|
||||
a.playChunk(loadChannelBuffer(a.channel, bufferSize*4))
|
||||
}
|
||||
time.Sleep(0)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
@ -29,9 +29,6 @@ func isPlaying(channel int) bool {
|
||||
return 0 < len(ch.buffer)
|
||||
}
|
||||
|
||||
func tick() {
|
||||
}
|
||||
|
||||
func initialize() {
|
||||
// Creating OpenAL device must be done after initializing UI. I'm not sure the reason.
|
||||
ch := make(chan struct{})
|
||||
|
3
run.go
3
run.go
@ -17,7 +17,6 @@ package ebiten
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/audio"
|
||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||
)
|
||||
|
||||
@ -93,8 +92,6 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
|
||||
runContext.newScreenHeight = 0
|
||||
runContext.newScreenScale = 0
|
||||
|
||||
audio.Tick()
|
||||
|
||||
if err := ui.DoEvents(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user