diff --git a/src/raudio.c b/src/raudio.c index 425497acf58e..ec97bdee1246 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -533,8 +533,9 @@ void CloseAudioDevice(void) { if (AUDIO.System.isReady) { - ma_mutex_uninit(&AUDIO.System.lock); + // Stop the device first (joins the callback thread) before destroying the mutex it locks ma_device_uninit(&AUDIO.System.device); + ma_mutex_uninit(&AUDIO.System.lock); ma_context_uninit(&AUDIO.System.context); AUDIO.System.isReady = false;