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 1b5b861735
commit 97fa948e5e

View File

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