mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
audio/vorbis/internal/stb: Use TypedArrayOf (#642)
This commit is contained in:
parent
c0ccc16767
commit
c6842f2cd8
@ -35,13 +35,16 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DecodeVorbis(buf []byte) ([]float32, int, int, error) {
|
func DecodeVorbis(buf []byte) ([]float32, int, int, error) {
|
||||||
r := js.Global().Get("_ebiten").Call("decodeVorbis", buf)
|
arr := js.TypedArrayOf(buf)
|
||||||
|
r := js.Global().Get("_ebiten").Call("decodeVorbis", arr)
|
||||||
|
arr.Release()
|
||||||
if r == js.Null() {
|
if r == js.Null() {
|
||||||
return nil, 0, 0, fmt.Errorf("audio/vorbis/internal/stb: decode failed")
|
return nil, 0, 0, fmt.Errorf("audio/vorbis/internal/stb: decode failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
data := make([]float32, r.Get("data").Get("length").Int())
|
data := make([]float32, r.Get("data").Get("length").Int())
|
||||||
// TODO: Use js.TypeArrayOf
|
arr = js.TypedArrayOf(data)
|
||||||
arr := js.ValueOf(data)
|
|
||||||
arr.Call("set", r.Get("data"))
|
arr.Call("set", r.Get("data"))
|
||||||
|
arr.Release()
|
||||||
return data, r.Get("channels").Int(), r.Get("sampleRate").Int(), nil
|
return data, r.Get("channels").Int(), r.Get("sampleRate").Int(), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user