mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -05:00
Prevent error due to LIST chunks
This commit is contained in:
parent
6f32a0bec7
commit
db1c89fa34
1 changed files with 11 additions and 1 deletions
|
@ -150,7 +150,17 @@ class ArrayBufferStream {
|
|||
* @return {number} the next 32 bit integer in the stream
|
||||
*/
|
||||
readInt32 () {
|
||||
const val = new Int32Array(this.arrayBuffer, this._position, 1)[0];
|
||||
// const sliced = this.arrayBuffer.slice
|
||||
let val;
|
||||
if (this._position % 4 === 0) {
|
||||
val = new Int32Array(this.arrayBuffer, this._position, 1)[0];
|
||||
} else {
|
||||
// Cannot read Int32 directly out because offset is not multiple of 4
|
||||
// Need to slice out the values first
|
||||
val = new Int32Array(
|
||||
this.arrayBuffer.slice(this._position, this._position + 4)
|
||||
)[0];
|
||||
}
|
||||
this._position += 4; // one 32 bit int is 4 bytes
|
||||
return val;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue