From 8d4adefb0e30fd1b481198b56b428e258e40cef9 Mon Sep 17 00:00:00 2001 From: headshot2017 <> Date: Fri, 15 Mar 2024 12:44:12 -0400 Subject: [PATCH] don't de-init audren on AudioBackend_Free() fixes sounds not playing when returning to launcher and starting the game again --- src/Audio.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Audio.c b/src/Audio.c index 0bc17d23b..a00ca5a56 100644 --- a/src/Audio.c +++ b/src/Audio.c @@ -956,7 +956,7 @@ static cc_bool AudioBackend_Init(void) { if (switchAudio) return true; switchAudio = true; - audrv_mutex = Mutex_Create(); + if (!audrv_mutex) audrv_mutex = Mutex_Create(); Mem_Set(audioPools, 0, sizeof(audioPools)); @@ -990,12 +990,9 @@ void AudioBackend_Tick(void) { } static void AudioBackend_Free(void) { - if (!switchAudio) return; - switchAudio = false; - Mutex_Free(audrv_mutex); - - audrvClose(&drv); - audrenExit(); + for (int i = 0; i < 24; i++) { + audrvVoiceStop(&drv, i); + } } #define AUDIO_HAS_BACKEND @@ -1155,7 +1152,7 @@ void Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks) { for (int j = 0; j < 64; j++) { if (audioPools[j].chunk != NULL) continue; - audioPools[j].chunk = chunks[i]; + audioPools[j].chunk = dst; audioPools[j].mpid = mpid; break; } @@ -1166,7 +1163,7 @@ void Audio_FreeChunks(void** chunks, int numChunks) { // remove memory pool from audren for (int i=0; i