Skip to content

Commit dcdcea1

Browse files
committed
WIP: notes and findings
The initial stackAlloc() is overflowing, seeming to need more space so this is accounted for.
1 parent 888d670 commit dcdcea1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/audio_worklet.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
4343
// may be required (with an arbitrary maximum of 16, for the case where a
4444
// multi-MB stack is passed), allocated at the *top* of the worklet's
4545
// stack (and whose addresses are fixed).
46-
this.maxBuffers = Math.min((Module['sz'] / (this.samplesPerChannel * 4)) | 0, /*sensible limit*/ 16);
46+
this.maxBuffers = Math.min(((Module['sz'] - /*stack guards?*/ 16) / (this.samplesPerChannel * 4)) | 0, /*sensible limit*/ 16);
4747
// These are still alloc'd to take advantage of the overflow checks, etc.
4848
var oldStackPtr = stackSave();
4949
var viewDataIdx = stackAlloc(this.maxBuffers * this.samplesPerChannel * 4) >> 2;
@@ -144,6 +144,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
144144
}
145145

146146
#if ASSERTIONS
147+
// TODO: addresses are now wrong
147148
k = outputDataPtr;
148149
for (i = outputViewsNeeded - 1; i >= 0; i--) {
149150
console.assert(this.outputViews[i].byteOffset == k, 'Internal error in addresses of the output array views');

0 commit comments

Comments
 (0)