audio/internal/readerdriver: Bug fix: createBuffer failed when the buffer size is 0

When the decoded audio size is exactly multiples of an internal
buffer size, the buffer's size becomes exactly zero when being
appended. In this case, createBuffer fails and the application
crashes.

This change fixes this issue by skipping to append a buffer in such
cases.

Closes #1635
This commit is contained in:
Hajime Hoshi 2021-05-07 02:22:51 +09:00
parent aa9f669ec3
commit 410d0f52e5

View File

@ -209,6 +209,10 @@ func (p *player) appendBuffer(this js.Value, args []js.Value) interface{} {
}
}
if len(bs) == 0 {
return nil
}
l, r := toLR(bs)
tl, tr := float32SliceToTypedArray(l), float32SliceToTypedArray(r)