From 4b8c40c7340a35a6e2a051d6a1f041f795293c72 Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 20 Apr 2023 00:20:31 -0700 Subject: [PATCH] Fix some audio corruption --- src/pc/controller/controller_sdl2.c | 12 ++++++------ src/pc/lua/utils/smlua_audio_utils.c | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pc/controller/controller_sdl2.c b/src/pc/controller/controller_sdl2.c index 4829cf5c..fc3063eb 100644 --- a/src/pc/controller/controller_sdl2.c +++ b/src/pc/controller/controller_sdl2.c @@ -38,17 +38,17 @@ extern u8 newcam_mouse; #endif -static bool init_ok; -static bool haptics_enabled; -static SDL_GameController *sdl_cntrl; -static SDL_Haptic *sdl_haptic; +static bool init_ok = false; +static bool haptics_enabled = false; +static SDL_GameController *sdl_cntrl = NULL; +static SDL_Haptic *sdl_haptic = NULL; static bool sBackgroundGamepad = false; static u32 num_joy_binds = 0; static u32 num_mouse_binds = 0; -static u32 joy_binds[MAX_JOYBINDS][2]; -static u32 mouse_binds[MAX_JOYBINDS][2]; +static u32 joy_binds[MAX_JOYBINDS][2] = { 0 }; +static u32 mouse_binds[MAX_JOYBINDS][2] = { 0 }; static bool joy_buttons[MAX_JOYBUTTONS] = { false }; static u32 mouse_buttons = 0; diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 065bb7cc..2628d183 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -43,6 +43,7 @@ static void smlua_audio_utils_reset(struct AudioOverride* override) { } void smlua_audio_utils_reset_all(void) { + audio_init(); for (s32 i = 0; i < MAX_AUDIO_OVERRIDE; i++) { if (sAudioOverrides[i].enabled) { sound_reset_background_music_default_volume(i); } smlua_audio_utils_reset(&sAudioOverrides[i]); @@ -116,6 +117,7 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu normalize_path(relPath); if (str_ends_with(relPath, m64path)) { struct AudioOverride* override = &sAudioOverrides[sequenceId]; + if (override->enabled) { audio_init(); } smlua_audio_utils_reset(override); LOG_INFO("Loading audio: %s", file->cachedPath); override->filename = strdup(file->cachedPath);