From 49cc504ced023c4875898adb29a1ed77e05484d2 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Mon, 17 Feb 2025 20:01:43 +0000 Subject: [PATCH] sdl2_driver: log errors from SDL_InitSubSystem and SDL_OpenAudioDevice (#425) --- UnleashedRecomp/apu/driver/sdl2_driver.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/UnleashedRecomp/apu/driver/sdl2_driver.cpp b/UnleashedRecomp/apu/driver/sdl2_driver.cpp index 5c85e25..f487620 100644 --- a/UnleashedRecomp/apu/driver/sdl2_driver.cpp +++ b/UnleashedRecomp/apu/driver/sdl2_driver.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include static PPCFunc* g_clientCallback{}; @@ -29,6 +30,9 @@ static void CreateAudioDevice() g_audioDevice = SDL_OpenAudioDevice(nullptr, 0, &desired, &obtained, 0); } + if (!g_audioDevice) + LOGFN_ERROR("Failed to open audio device: {}", SDL_GetError()); + g_downMixToStereo = (obtained.channels == 2); } @@ -36,7 +40,13 @@ void XAudioInitializeSystem() { SDL_SetHint(SDL_HINT_AUDIO_CATEGORY, "playback"); SDL_SetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME, "Unleashed Recompiled"); - SDL_InitSubSystem(SDL_INIT_AUDIO); + + if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) + { + LOGFN_ERROR("Failed to init audio subsystem: {}", SDL_GetError()); + return; + } + CreateAudioDevice(); }