Fix some audio corruption

This commit is contained in:
MysterD 2023-04-20 00:20:31 -07:00
parent 552f97bf4b
commit 4b8c40c734
2 changed files with 8 additions and 6 deletions

View File

@ -38,17 +38,17 @@
extern u8 newcam_mouse; extern u8 newcam_mouse;
#endif #endif
static bool init_ok; static bool init_ok = false;
static bool haptics_enabled; static bool haptics_enabled = false;
static SDL_GameController *sdl_cntrl; static SDL_GameController *sdl_cntrl = NULL;
static SDL_Haptic *sdl_haptic; static SDL_Haptic *sdl_haptic = NULL;
static bool sBackgroundGamepad = false; static bool sBackgroundGamepad = false;
static u32 num_joy_binds = 0; static u32 num_joy_binds = 0;
static u32 num_mouse_binds = 0; static u32 num_mouse_binds = 0;
static u32 joy_binds[MAX_JOYBINDS][2]; static u32 joy_binds[MAX_JOYBINDS][2] = { 0 };
static u32 mouse_binds[MAX_JOYBINDS][2]; static u32 mouse_binds[MAX_JOYBINDS][2] = { 0 };
static bool joy_buttons[MAX_JOYBUTTONS] = { false }; static bool joy_buttons[MAX_JOYBUTTONS] = { false };
static u32 mouse_buttons = 0; static u32 mouse_buttons = 0;

View File

@ -43,6 +43,7 @@ static void smlua_audio_utils_reset(struct AudioOverride* override) {
} }
void smlua_audio_utils_reset_all(void) { void smlua_audio_utils_reset_all(void) {
audio_init();
for (s32 i = 0; i < MAX_AUDIO_OVERRIDE; i++) { for (s32 i = 0; i < MAX_AUDIO_OVERRIDE; i++) {
if (sAudioOverrides[i].enabled) { sound_reset_background_music_default_volume(i); } if (sAudioOverrides[i].enabled) { sound_reset_background_music_default_volume(i); }
smlua_audio_utils_reset(&sAudioOverrides[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); normalize_path(relPath);
if (str_ends_with(relPath, m64path)) { if (str_ends_with(relPath, m64path)) {
struct AudioOverride* override = &sAudioOverrides[sequenceId]; struct AudioOverride* override = &sAudioOverrides[sequenceId];
if (override->enabled) { audio_init(); }
smlua_audio_utils_reset(override); smlua_audio_utils_reset(override);
LOG_INFO("Loading audio: %s", file->cachedPath); LOG_INFO("Loading audio: %s", file->cachedPath);
override->filename = strdup(file->cachedPath); override->filename = strdup(file->cachedPath);