Skip to content

Commit 7f4c6b9

Browse files
committed
Fix post function on AudioWorklet
This commit changes the old term `readAsmConstArgs` to the new term `readEmAsmArgs`, due to conflict of #16449 and #18218 Background history: 1. #16449 proposed, introducing AudioWorklet earlier 2. #18218 proposed, renaming readAsmConstArgs to readEmAsmArgs 3. #18218 merged earlier 4. #16449 merged later, using the old term `readAsmConstArgs`
1 parent c08204e commit 7f4c6b9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/library_webaudio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ let LibraryWebAudio = {
378378
emscripten_audio_worklet_post_function_3(audioContext, funcPtr, arg0, arg1, arg2);
379379
},
380380

381-
emscripten_audio_worklet_post_function_sig__deps: ['$readAsmConstArgs'],
381+
emscripten_audio_worklet_post_function_sig__deps: ['$readEmAsmArgs'],
382382
emscripten_audio_worklet_post_function_sig: (audioContext, funcPtr, sigPtr, varargs) => {
383383
#if ASSERTIONS
384384
assert(audioContext >= 0);
@@ -387,7 +387,7 @@ let LibraryWebAudio = {
387387
assert(UTF8ToString(sigPtr)[0] != 'v', 'Do NOT specify the return argument in the signature string for a call to emscripten_audio_worklet_post_function_sig(), just pass the function arguments.');
388388
assert(varargs);
389389
#endif
390-
(audioContext ? EmAudio[audioContext].audioWorklet.bootstrapMessage.port : globalThis['messagePort']).postMessage({'_wsc': funcPtr, 'x': readAsmConstArgs(sigPtr, varargs) });
390+
(audioContext ? EmAudio[audioContext].audioWorklet.bootstrapMessage.port : globalThis['messagePort']).postMessage({'_wsc': funcPtr, 'x': readEmAsmArgs(sigPtr, varargs) });
391391
}
392392
};
393393

test/webaudio/audioworklet_post_function.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// emscripten_audio_worklet_post_function_*() API.
88

99
// This event will fire on the main thread.
10-
void MessageReceivedOnMainThread(int d, int e, int f) {
11-
printf("MessageReceivedOnMainThread: d=%d, e=%d, f=%d\n", d, e, f);
10+
void MessageReceivedOnMainThread(int d, double e, int f) {
11+
printf("MessageReceivedOnMainThread: d=%d, e=%f, f=%d\n", d, e, f);
1212
assert(!emscripten_current_thread_is_audio_worklet());
13-
assert(d == 1 && e == 2 && f == 3);
13+
assert(d == 1 && e == 2.0f && f == 3);
1414
#ifdef REPORT_RESULT
1515
REPORT_RESULT(1); // test succeeded, were able to post a message from main thread to audio thread and back!
1616
#endif
@@ -21,7 +21,7 @@ void MessageReceivedInAudioWorkletThread(int a, int b) {
2121
printf("MessageReceivedInAudioWorkletThread: a=%d, b=%d\n", a, b);
2222
assert(emscripten_current_thread_is_audio_worklet());
2323
assert(a == 42 && b == 9000);
24-
emscripten_audio_worklet_post_function_viii(EMSCRIPTEN_AUDIO_MAIN_THREAD, MessageReceivedOnMainThread, /*d=*/1, /*e=*/2, /*f=*/3);
24+
emscripten_audio_worklet_post_function_sig(EMSCRIPTEN_AUDIO_MAIN_THREAD, (void *)MessageReceivedOnMainThread, "idi", /*d=*/1, /*e=*/2.0f, /*f=*/3);
2525
}
2626

2727
// This callback will fire when the audio worklet thread has been initialized.

0 commit comments

Comments
 (0)