From 8dbcaf6d6521b24ee9264b94a0598f702c75dffb Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Tue, 24 Jun 2025 15:54:26 -0700 Subject: [PATCH] Allow running game without audio device (#426) * Allow running game without audio device * Remove dot * Add SDL error to message --- LEGO1/omni/src/audio/mxsoundmanager.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/LEGO1/omni/src/audio/mxsoundmanager.cpp b/LEGO1/omni/src/audio/mxsoundmanager.cpp index afb9b21e..f865ebf0 100644 --- a/LEGO1/omni/src/audio/mxsoundmanager.cpp +++ b/LEGO1/omni/src/audio/mxsoundmanager.cpp @@ -9,6 +9,8 @@ #include "mxticklethread.h" #include "mxwavepresenter.h" +#include + DECOMP_SIZE_ASSERT(MxSoundManager, 0x3c); // GLOBAL LEGO1 0x10101420 @@ -98,12 +100,17 @@ MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread) spec.format = SDL_AUDIO_F32; spec.channels = ma_engine_get_channels(m_engine); - if ((m_stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, &AudioStreamCallback, this)) == + if ((m_stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, &AudioStreamCallback, this)) != NULL) { - goto done; + SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(m_stream)); + } + else { + SDL_LogError( + SDL_LOG_CATEGORY_APPLICATION, + "Failed to open default audio device for playback: %s", + SDL_GetError() + ); } - - SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(m_stream)); if (p_createThread) { m_thread = new MxTickleThread(this, p_frequencyMS);