Skip to content

Commit 5752568

Browse files
committed
Initial empty test
1 parent 8735e88 commit 5752568

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

test/test_interactive.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ def test_audio_worklet(self):
293293
self.btest('webaudio/audioworklet.c', expected='0', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '--preload-file', test_file('hello_world.c') + '@/'])
294294
self.btest('webaudio/audioworklet.c', expected='0', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-pthread'])
295295

296-
# Tests AudioWorklet with emscripten_futex_wake().
296+
# Tests AudioWorklet with emscripten_lock_busyspin_wait_acquire() and friends.
297297
@also_with_minimal_runtime
298-
def test_audio_worklet_emscripten_futex_wake(self):
299-
self.btest('webaudio/audioworklet_emscripten_futex_wake.cpp', expected='0', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-pthread', '-sPTHREAD_POOL_SIZE=2'])
298+
def test_audio_worklet_emscripten_locks(self):
299+
self.btest('webaudio/audioworklet_emscripten_locks.cpp', expected='0', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-pthread', '-sPTHREAD_POOL_SIZE=2'])
300300

301301
# Tests a second AudioWorklet example: sine wave tone generator.
302302
def test_audio_worklet_tone_generator(self):

test/webaudio/audioworklet_emscripten_locks.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
#include <emscripten/wasm_worker.h>
12
#include <emscripten/webaudio.h>
2-
#include <emscripten/threading.h>
33
#include <stdio.h>
44
#include <stdlib.h>
55
#include <assert.h>
66

7-
// Tests that
8-
// - _emscripten_thread_supports_atomics_wait() returns true in a Wasm Audio Worklet.
9-
// - emscripten_futex_wake() does not crash in a Wasm Audio Worklet.
10-
// - emscripten_futex_wait() does not crash in a Wasm Audio Worklet.
7+
// Tests that these audio worklet compatible functions work:
8+
// - emscripten_lock_init()
9+
// - emscripten_lock_busyspin_wait_acquire()
10+
// - emscripten_lock_busyspin_waitinf_acquire()
11+
// - emscripten_lock_try_acquire()
12+
// - emscripten_lock_release()
1113
// - emscripten_get_now() does not crash in a Wasm Audio Worklet.
1214

13-
int futexLocation = 0;
15+
// Todo: add/find a way to verify atomic wait fails?
16+
17+
emscripten_lock_t testLock = EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER;
1418
int testSuccess = 0;
1519

1620
bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) {
17-
int supportsAtomicWait = _emscripten_thread_supports_atomics_wait();
18-
printf("supportsAtomicWait: %d\n", supportsAtomicWait);
19-
assert(!supportsAtomicWait);
20-
emscripten_futex_wake(&futexLocation, 1);
21+
//emscripten_futex_wake(&futexLocation, 1);
2122
printf("%f\n", emscripten_get_now());
2223

23-
emscripten_futex_wait(&futexLocation, 1, /*maxWaitMs=*/2);
24+
//emscripten_futex_wait(&futexLocation, 1, /*maxWaitMs=*/2);
2425
testSuccess = 1;
2526

2627
return false;
@@ -64,6 +65,7 @@ void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool s
6465
uint8_t wasmAudioWorkletStack[4096];
6566

6667
int main() {
68+
emscripten_lock_init(&testLock);
6769
emscripten_set_timeout_loop(PollTestSuccess, 10, 0);
6870
EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(0);
6971
emscripten_start_wasm_audio_worklet_thread_async(context, wasmAudioWorkletStack, sizeof(wasmAudioWorkletStack), WebAudioWorkletThreadInitialized, 0);

0 commit comments

Comments
 (0)