Skip to content

Commit 5695571

Browse files
committed
Added explicit audio shutdown
1 parent f81f4e3 commit 5695571

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/webaudio/audioworklet_emscripten_locks.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// - emscripten_lock_release()
1414
// - emscripten_get_now()
1515

16+
// Global audio context
17+
EMSCRIPTEN_WEBAUDIO_T context;
18+
1619
// Internal, found in 'system/lib/pthread/threading_internal.h' (and requires building with -pthread)
1720
int _emscripten_thread_supports_atomics_wait(void);
1821

@@ -48,6 +51,7 @@ double startTime = 0;
4851

4952
void do_exit() {
5053
emscripten_out("Test success");
54+
emscripten_destroy_audio_context(context);
5155
emscripten_terminate_all_wasm_workers();
5256
emscripten_force_exit(0);
5357
}
@@ -186,7 +190,8 @@ int main() {
186190
startTime = emscripten_get_now();
187191

188192
// Audio processor callback setup
189-
EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(NULL);
193+
context = emscripten_create_audio_context(NULL);
194+
assert(context);
190195
emscripten_start_wasm_audio_worklet_thread_async(context, wasmAudioWorkletStack, sizeof(wasmAudioWorkletStack), WebAudioWorkletThreadInitialized, NULL);
191196

192197
// Worker thread setup

0 commit comments

Comments
 (0)