Skip to content

Commit b2219a2

Browse files
authored
Update audioWorklet.js
1 parent 5f05388 commit b2219a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

audioWorklet.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,21 @@ class AudioDataWorkletStream extends AudioWorkletProcessor {
3838
});
3939
}
4040
process(inputs, outputs) {
41+
if (this.offset === this.uint8.length) {
42+
this.endOfStream();
43+
return false;
44+
}
4145
const channels = outputs.flat();
4246
const uint8 = new Uint8Array(512);
4347
for (let i = 0; i < 512; i++, this.offset++) {
4448
if (this.offset === this.uint8.length) {
45-
this.port.postMessage({ ended: true, currentTime, currentFrame });
46-
return false;
49+
break;
4750
}
4851
uint8[i] = this.uint8[this.offset];
4952
}
5053
const uint16 = new Uint16Array(uint8.buffer);
5154
CODECS.get(this.codec)(uint16, channels);
55+
console.log(this.offset, this.index);
5256
return true;
5357
}
5458
}

0 commit comments

Comments
 (0)