mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Bug fix: Add gopherjs:blocking for the latest GopherJS
This commit is contained in:
parent
249add3979
commit
fdedee9aab
@ -28,24 +28,26 @@ const bufferSize = 1024
|
||||
|
||||
func audioProcess(channel int) func(e js.Object) {
|
||||
return func(e js.Object) {
|
||||
defer func() {
|
||||
currentPosition += bufferSize
|
||||
}()
|
||||
go func() {
|
||||
defer func() {
|
||||
currentPosition += bufferSize
|
||||
}()
|
||||
|
||||
l := e.Get("outputBuffer").Call("getChannelData", 0)
|
||||
r := e.Get("outputBuffer").Call("getChannelData", 1)
|
||||
inputL, inputR := loadChannelBuffer(channel, bufferSize)
|
||||
const max = 1 << 15
|
||||
for i := 0; i < bufferSize; i++ {
|
||||
// TODO: Use copyFromChannel?
|
||||
if len(inputL) <= i {
|
||||
l.SetIndex(i, 0)
|
||||
r.SetIndex(i, 0)
|
||||
continue
|
||||
l := e.Get("outputBuffer").Call("getChannelData", 0)
|
||||
r := e.Get("outputBuffer").Call("getChannelData", 1)
|
||||
inputL, inputR := loadChannelBuffer(channel, bufferSize)
|
||||
const max = 1 << 15
|
||||
for i := 0; i < bufferSize; i++ {
|
||||
// TODO: Use copyFromChannel?
|
||||
if len(inputL) <= i {
|
||||
l.SetIndex(i, 0)
|
||||
r.SetIndex(i, 0)
|
||||
continue
|
||||
}
|
||||
l.SetIndex(i, float64(inputL[i])/max)
|
||||
r.SetIndex(i, float64(inputR[i])/max)
|
||||
}
|
||||
l.SetIndex(i, float64(inputL[i])/max)
|
||||
r.SetIndex(i, float64(inputR[i])/max)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
3
run.go
3
run.go
@ -79,7 +79,8 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
|
||||
if err := graphicsContext.preUpdate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f(graphicsContext.screen); err != nil {
|
||||
err := f(graphicsContext.screen) //gopherjs:blocking
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := graphicsContext.postUpdate(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user