Skip to content

Commit 466a447

Browse files
committed
Work-in-progress 64-bit changes
Mostly getting things to compile, which is does but now we have an assert in process().
1 parent ad0abee commit 466a447

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

src/audio_worklet.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
112112

113113
// Copy input audio descriptor structs and data to Wasm
114114
inputsPtr = dataPtr;
115-
k = inputsPtr >> 2;
115+
k = inputsPtr >>> 2;
116116
dataPtr += numInputs * {{{ C_STRUCTS.AudioSampleFrame.__size__ }}};
117117
for (i of inputList) {
118118
// Write the AudioSampleFrame struct instance
@@ -122,7 +122,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
122122
k += {{{ C_STRUCTS.AudioSampleFrame.__size__ / 4 }}};
123123
// Marshal the input audio sample data for each audio channel of this input
124124
for (j of i) {
125-
HEAPF32.set(j, dataPtr>>2);
125+
HEAPF32.set(j, dataPtr>>>2);
126126
dataPtr += bytesPerChannel;
127127
}
128128
}
@@ -179,7 +179,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
179179
#endif
180180

181181
// Call out to Wasm callback to perform audio processing
182-
if (didProduceAudio = this.callbackFunction(numInputs, inputsPtr, numOutputs, outputsPtr, numParams, paramsPtr, this.userData)) {
182+
if (didProduceAudio = this.callbackFunction(numInputs, BigInt(inputsPtr), numOutputs, BigInt(outputsPtr), numParams, BigInt(paramsPtr), this.userData)) {
183183
// Read back the produced audio data to all outputs and their channels.
184184
// The preallocated 'outputViews' already have the correct offsets and
185185
// sizes into the stack (recall from the ctor that they run backwards).

src/lib/libwebaudio.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let LibraryWebAudio = {
7878
#if WEBAUDIO_DEBUG
7979
console.log(`emscripten_resume_audio_context_async() callback: New audio state="${EmAudio[contextHandle].state}", ID=${state}`);
8080
#endif
81-
{{{ makeDynCall('viii', 'callback') }}}(contextHandle, state, userData);
81+
{{{ makeDynCall('viip', 'callback') }}}(contextHandle, state, userData);
8282
}
8383
#if WEBAUDIO_DEBUG
8484
console.log(`emscripten_resume_audio_context_async() resuming...`);
@@ -162,12 +162,13 @@ let LibraryWebAudio = {
162162
console.log(`emscripten_start_wasm_audio_worklet_thread_async() adding audioworklet.js...`);
163163
#endif
164164

165-
let audioWorkletCreationFailed = () => {
165+
let audioWorkletCreationFailed = (err) => {
166166
#if WEBAUDIO_DEBUG
167167
// Note about Cross-Origin here: a lack of Cross-Origin-Opener-Policy and
168168
// Cross-Origin-Embedder-Policy headers to the client request will result
169169
// in the worklet file failing to load.
170170
console.error(`emscripten_start_wasm_audio_worklet_thread_async() addModule() failed! Are the Cross-Origin headers being set?`);
171+
if (err) console.error(err);
171172
#endif
172173
{{{ makeDynCall('viip', 'callback') }}}(contextHandle, 0/*EM_FALSE*/, userData);
173174
};
@@ -225,7 +226,7 @@ let LibraryWebAudio = {
225226
#if WEBAUDIO_DEBUG
226227
console.log(`emscripten_start_wasm_audio_worklet_thread_async() addModule() of main application JS completed`);
227228
#endif
228-
{{{ makeDynCall('viii', 'callback') }}}(contextHandle, 1/*EM_TRUE*/, userData);
229+
{{{ makeDynCall('viip', 'callback') }}}(contextHandle, 1/*EM_TRUE*/, userData);
229230
}).catch(audioWorkletCreationFailed);
230231
},
231232

@@ -272,8 +273,8 @@ let LibraryWebAudio = {
272273
'_wpn': UTF8ToString(HEAPU32[options]),
273274
'ap': audioParams,
274275
'ch': contextHandle,
275-
'cb': callback,
276-
'ud': userData
276+
'cb': BigInt(callback),
277+
'ud': BigInt(userData)
277278
});
278279
},
279280

@@ -297,8 +298,8 @@ let LibraryWebAudio = {
297298
numberOfOutputs: HEAP32[options+1],
298299
outputChannelCount: HEAPU32[options+2] ? readChannelCountArray(HEAPU32[options+2]>>2, HEAP32[options+1]) : void 0,
299300
processorOptions: {
300-
'cb': callback,
301-
'ud': userData,
301+
'cb': BigInt(callback),
302+
'ud': BigInt(userData),
302303
'sc': emscriptenGetContextQuantumSize(contextHandle)
303304
}
304305
} : void 0;

test/webaudio/audioworklet_test_shared.inc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ EM_JS(EMSCRIPTEN_WEBAUDIO_T, createTrack, (EMSCRIPTEN_WEBAUDIO_T ctxID, const ch
2828
var context = emscriptenGetAudioObject(ctxID);
2929
if (context) {
3030
var audio = document.createElement('audio');
31+
32+
// Workaround for UTF8ToString() needing a JS number
33+
url = Number(BigInt.asUintN(53, url));
34+
3135
audio.src = UTF8ToString(url);
3236
audio.loop = looping;
3337
var track = context.createMediaElementSource(audio);
@@ -82,11 +86,15 @@ void initialised(EMSCRIPTEN_WEBAUDIO_T context, bool success, void* data) {
8286
emscripten_create_wasm_audio_worklet_processor_async(context, &opts, &processorCreated, NULL);
8387
}
8488

89+
8590
// Common entry point for the mixer tests
8691
int main() {
87-
static char workletStack[AUDIO_STACK_SIZE];
92+
char* const emptySpace = malloc(2147483648);
93+
(void) emptySpace;
94+
char* const workletStack = malloc(AUDIO_STACK_SIZE);
95+
//static char workletStack[AUDIO_STACK_SIZE];
8896
EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(NULL);
89-
emscripten_start_wasm_audio_worklet_thread_async(context, workletStack, sizeof workletStack, &initialised, NULL);
97+
emscripten_start_wasm_audio_worklet_thread_async(context, workletStack, AUDIO_STACK_SIZE, &initialised, NULL);
9098
#ifndef BROWSER_TEST
9199
// Special case: browser tests need to exit instantly, interactive tests need to wait
92100
emscripten_runtime_keepalive_push();

0 commit comments

Comments
 (0)