@@ -113,8 +113,8 @@ function createWasmAudioWorkletProcessor(audioParams) {
113
113
// _emscripten_stack_alloc(), as were the output views, and so to ensure
114
114
// the views fall on the correct addresses (and we finish at the stacktop)
115
115
// bytes are added and the start advanced.
116
- entry = ( stackMemoryNeeded + 15 ) & ~ 15 ;
117
- var dataPtr = stackAlloc ( entry ) + ( entry - stackMemoryNeeded ) ;
116
+ var alignedNeededStack = ( stackMemoryNeeded + 15 ) & ~ 15 ;
117
+ var dataPtr = stackAlloc ( alignedNeededStack ) ;
118
118
119
119
// Copy input audio descriptor structs and data to Wasm (recall, structs
120
120
// first, audio data after). 'inputsPtr' is the start of the C callback's
@@ -150,6 +150,12 @@ function createWasmAudioWorkletProcessor(audioParams) {
150
150
dataPtr + = subentry . length * { { { getNativeTypeSize ( 'float' ) } } } ;
151
151
}
152
152
153
+ // TODO: why does Chrome wasm64 (Chrome has weird rules for params) need
154
+ // the manual alignment here? An off-by-one somewhere? outputsPtr is
155
+ // getting clobbered otherwise, is the struct correctly aligned? Do more
156
+ // stack allocs instead? Probably needs alignments between struct writes?
157
+ dataPtr + = alignedNeededStack - stackMemoryNeeded ;
158
+
153
159
// Copy output audio descriptor structs to Wasm. 'outputsPtr' is the start
154
160
// of the C callback's output AudioSampleFrame.
155
161
// Note: dataPtr after the struct offsets should now be 16-byte aligned.
0 commit comments