@@ -45,6 +45,7 @@ _Atomic Test whichTest = TEST_HAS_WAIT;
4545double startTime = 0 ;
4646
4747bool 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
116117bool 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