Skip to content

Commit 0c45bbd

Browse files
authored
Add some debugging to audioworklet_emscripten_locks.c. NFC (emscripten-core#24203)
I'm having some trouble getting this test to pass in emscripten-core#24190 and even having trouble getting to pass on my desktop.
1 parent 45056f1 commit 0c45bbd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/webaudio/audioworklet_emscripten_locks.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ _Atomic Test whichTest = TEST_HAS_WAIT;
4545
double startTime = 0;
4646

4747
bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) {
48+
assert(emscripten_current_thread_is_audio_worklet());
4849
int result = 0;
4950
switch (whichTest) {
5051
case TEST_HAS_WAIT:
@@ -69,7 +70,7 @@ bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs,
6970
whichTest = TEST_WAIT_ACQUIRE;
7071
case TEST_WAIT_ACQUIRE:
7172
// Will get unlocked in main thread, so should quickly acquire
72-
result = emscripten_lock_busyspin_wait_acquire(&testLock, 100);
73+
result = emscripten_lock_busyspin_wait_acquire(&testLock, 10000);
7374
emscripten_outf("TEST_WAIT_ACQUIRE: %d (expect: 1)", result);
7475
assert(result);
7576
whichTest = TEST_RELEASE;
@@ -114,10 +115,16 @@ EM_JS(void, InitHtmlUi, (EMSCRIPTEN_WEBAUDIO_T audioContext), {
114115
});
115116

116117
bool MainLoop(double time, void* data) {
118+
assert(!emscripten_current_thread_is_audio_worklet());
119+
static int didUnlock = false;
117120
switch (whichTest) {
118121
case TEST_WAIT_ACQUIRE:
119-
// Release here to acquire in process
120-
emscripten_lock_release(&testLock);
122+
if (!didUnlock) {
123+
emscripten_out("main thread releasing lock");
124+
// Release here to acquire in process
125+
emscripten_lock_release(&testLock);
126+
didUnlock = true;
127+
}
121128
break;
122129
case TEST_WAIT_INFINTE_1:
123130
// Spin here until released in process (but don't change test until we know this case ran)

0 commit comments

Comments
 (0)