Bug fix: Add gopherjs:blocking for the latest GopherJS

This commit is contained in:
Hajime Hoshi 2015-02-09 11:16:23 +09:00
parent 249add3979
commit fdedee9aab
2 changed files with 20 additions and 17 deletions

View File

@ -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
View File

@ -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 {