From 12c3f084f68f776103409cd6db5200805d4f5bee Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 2 Feb 2024 20:12:01 -0500 Subject: [PATCH] Fixes --- .../lego/legoomni/include/legosoundmanager.h | 5 ++- .../legoomni/include/legounknown100d6b4c.h | 5 ++- .../legoomni/src/audio/legosoundmanager.cpp | 35 +++++++++++-------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legosoundmanager.h b/LEGO1/lego/legoomni/include/legosoundmanager.h index 5a29712a..89e51165 100644 --- a/LEGO1/lego/legoomni/include/legosoundmanager.h +++ b/LEGO1/lego/legoomni/include/legosoundmanager.h @@ -24,8 +24,11 @@ class LegoSoundManager : public MxSoundManager { void Init(); void Destroy(MxBool p_fromDestructor); - IDirectSound3DListener* m_listener; // 0x3c + LPDIRECTSOUND3DLISTENER m_listener; // 0x3c LegoUnknown100d6b4c* m_unk0x40; // 0x40 }; +// GLOBAL: LEGO1 0x100db6d0 +// IID_IDirectSound3DListener + #endif // LEGOSOUNDMANAGER_H diff --git a/LEGO1/lego/legoomni/include/legounknown100d6b4c.h b/LEGO1/lego/legoomni/include/legounknown100d6b4c.h index 9a63eeac..18192f9a 100644 --- a/LEGO1/lego/legoomni/include/legounknown100d6b4c.h +++ b/LEGO1/lego/legoomni/include/legounknown100d6b4c.h @@ -13,9 +13,12 @@ class LegoUnknown100d6b4c { LegoUnknown100d6b4c(); ~LegoUnknown100d6b4c(); - virtual MxResult Tickle(); // vtable+0x0 + virtual MxResult Tickle(); // vtable+0x00 void FUN_1003dc40(LegoCacheSound** p_und); + +private: + undefined m_pad[0x1c]; }; #endif // LEGOUNKNOWN100D6B4C_H diff --git a/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp b/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp index 1bbe401e..748eecdb 100644 --- a/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp +++ b/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp @@ -37,30 +37,36 @@ MxResult LegoSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread) { MxBool locked = FALSE; MxResult result = FAILURE; + if (MxSoundManager::Create(10, FALSE) == SUCCESS) { m_criticalSection.Enter(); locked = TRUE; - if (MxOmni::IsSound3D()) { - if (m_dsBuffer->QueryInterface(IID_IDirectSound3DListener, (LPVOID*) &m_listener) == S_OK) { - MxOmni* omni = MxOmni::GetInstance(); - IDirectSound* sound; - if (omni && omni->GetSoundManager() && (sound = omni->GetSoundManager()->GetDirectSound())) { - DSCAPS caps; - memset(&caps, 0, sizeof(DSCAPS)); - caps.dwSize = sizeof(DSCAPS); - if (sound->GetCaps(&caps) == S_OK && caps.dwMaxHw3DAllBuffers == 0) { - m_listener->SetDistanceFactor(0.026315790f, 0); - m_listener->SetRolloffFactor(10, 0); - } + if (MxOmni::IsSound3D()) { + if (m_dsBuffer->QueryInterface(IID_IDirectSound3DListener, (LPVOID*) &m_listener) != S_OK) { + goto done; + } + + MxOmni* omni = MxOmni::GetInstance(); + LPDIRECTSOUND sound; + + if (omni && omni->GetSoundManager() && (sound = omni->GetSoundManager()->GetDirectSound())) { + DSCAPS caps; + memset(&caps, 0, sizeof(DSCAPS)); + caps.dwSize = sizeof(DSCAPS); + + if (sound->GetCaps(&caps) == S_OK && caps.dwMaxHw3DAllBuffers == 0) { + m_listener->SetDistanceFactor(0.026315790f, 0); + m_listener->SetRolloffFactor(10, 0); } } } - m_unk0x40 = new LegoUnknown100d6b4c(); + m_unk0x40 = new LegoUnknown100d6b4c; result = SUCCESS; } +done: if (result != SUCCESS) { Destroy(); } @@ -68,6 +74,7 @@ MxResult LegoSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread) if (locked) { m_criticalSection.Leave(); } + return result; } @@ -81,7 +88,7 @@ void LegoSoundManager::Destroy() MxResult LegoSoundManager::Tickle() { MxMediaManager::Tickle(); - MxAutoLocker lock(&this->m_criticalSection); + MxAutoLocker lock(&m_criticalSection); return m_unk0x40->Tickle(); }