mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +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) {
|
func audioProcess(channel int) func(e js.Object) {
|
||||||
return func(e js.Object) {
|
return func(e js.Object) {
|
||||||
defer func() {
|
go func() {
|
||||||
currentPosition += bufferSize
|
defer func() {
|
||||||
}()
|
currentPosition += bufferSize
|
||||||
|
}()
|
||||||
|
|
||||||
l := e.Get("outputBuffer").Call("getChannelData", 0)
|
l := e.Get("outputBuffer").Call("getChannelData", 0)
|
||||||
r := e.Get("outputBuffer").Call("getChannelData", 1)
|
r := e.Get("outputBuffer").Call("getChannelData", 1)
|
||||||
inputL, inputR := loadChannelBuffer(channel, bufferSize)
|
inputL, inputR := loadChannelBuffer(channel, bufferSize)
|
||||||
const max = 1 << 15
|
const max = 1 << 15
|
||||||
for i := 0; i < bufferSize; i++ {
|
for i := 0; i < bufferSize; i++ {
|
||||||
// TODO: Use copyFromChannel?
|
// TODO: Use copyFromChannel?
|
||||||
if len(inputL) <= i {
|
if len(inputL) <= i {
|
||||||
l.SetIndex(i, 0)
|
l.SetIndex(i, 0)
|
||||||
r.SetIndex(i, 0)
|
r.SetIndex(i, 0)
|
||||||
continue
|
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 {
|
if err := graphicsContext.preUpdate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := f(graphicsContext.screen); err != nil {
|
err := f(graphicsContext.screen) //gopherjs:blocking
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := graphicsContext.postUpdate(); err != nil {
|
if err := graphicsContext.postUpdate(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user