MxAudioManager: Destructor, LockedReinitialize, Reinitialize (#125)

* MxAudioManager: Destructor, LockedReinitialize

* MxAudioManager::Reinitialize, fix LockedReinitialize logic

* MxAudioManager cleanup

- fix param in LockedReinitialize, mark that function as private/give it a better param name

* Match LockedReinitialize, fix function declarations, add/match InitPresenters

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Joshua Peisach 2023-09-19 10:42:39 -04:00 committed by GitHub
parent c67e537508
commit 5617e0e044
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 96 additions and 42 deletions

View file

@ -93,6 +93,7 @@ add_library(lego1 SHARED
LEGO1/motorcycle.cpp LEGO1/motorcycle.cpp
LEGO1/mxatomid.cpp LEGO1/mxatomid.cpp
LEGO1/mxatomidcounter.cpp LEGO1/mxatomidcounter.cpp
LEGO1/mxaudiomanager.cpp
LEGO1/mxaudiopresenter.cpp LEGO1/mxaudiopresenter.cpp
LEGO1/mxautolocker.cpp LEGO1/mxautolocker.cpp
LEGO1/mxbackgroundaudiomanager.cpp LEGO1/mxbackgroundaudiomanager.cpp
@ -159,7 +160,6 @@ add_library(lego1 SHARED
LEGO1/mxticklemanager.cpp LEGO1/mxticklemanager.cpp
LEGO1/mxtimer.cpp LEGO1/mxtimer.cpp
LEGO1/mxtransitionmanager.cpp LEGO1/mxtransitionmanager.cpp
LEGO1/mxunknown100dc6e0.cpp
LEGO1/mxvariable.cpp LEGO1/mxvariable.cpp
LEGO1/mxvariabletable.cpp LEGO1/mxvariabletable.cpp
LEGO1/mxvector.cpp LEGO1/mxvector.cpp

64
LEGO1/mxaudiomanager.cpp Normal file
View file

@ -0,0 +1,64 @@
#include "mxaudiomanager.h"
DECOMP_SIZE_ASSERT(MxAudioManager, 0x30);
// GLOBAL: LEGO1 0x10102108
MxS32 MxAudioManager::g_unkCount = 0;
// OFFSET: LEGO1 0x100b8d00
MxAudioManager::MxAudioManager()
{
Init();
}
// OFFSET: LEGO1 0x100b8d90
MxAudioManager::~MxAudioManager()
{
LockedReinitialize(TRUE);
}
// OFFSET: LEGO1 0x100b8df0
void MxAudioManager::Init()
{
this->m_unk2c = 100;
}
// OFFSET: LEGO1 0x100b8e00
void MxAudioManager::LockedReinitialize(MxBool p_skipDestroy)
{
this->m_criticalSection.Enter();
g_unkCount--;
Init();
this->m_criticalSection.Leave();
if (!p_skipDestroy)
MxMediaManager::Destroy();
}
// OFFSET: LEGO1 0x100b8e40
MxResult MxAudioManager::InitPresenters()
{
MxResult result = FAILURE;
MxBool success = FALSE;
if (MxMediaManager::InitPresenters() == SUCCESS) {
this->m_criticalSection.Enter();
success = TRUE;
result = SUCCESS;
g_unkCount++;
}
if (result)
Destroy();
if (success)
this->m_criticalSection.Leave();
return result;
}
// OFFSET: LEGO1 0x100b8e90
void MxAudioManager::Destroy()
{
LockedReinitialize(FALSE);
}

28
LEGO1/mxaudiomanager.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef MXAUDIOMANAGER_H
#define MXAUDIOMANAGER_H
#include "decomp.h"
#include "mxmediamanager.h"
// VTABLE 0x100dc6e0
class MxAudioManager : public MxMediaManager
{
public:
MxAudioManager();
virtual ~MxAudioManager() override;
virtual MxResult InitPresenters(); // vtable+14
virtual void Destroy(); // vtable+18
private:
void LockedReinitialize(MxBool);
static MxS32 g_unkCount;
protected:
void Init();
undefined4 m_unk2c;
};
#endif // MXAUDIOMANAGER_H

View file

@ -1,12 +1,12 @@
#ifndef MXSOUNDMANAGER_H #ifndef MXSOUNDMANAGER_H
#define MXSOUNDMANAGER_H #define MXSOUNDMANAGER_H
#include "mxunknown100dc6e0.h" #include "mxaudiomanager.h"
// VTABLE 0x100dc128 // VTABLE 0x100dc128
// SIZE 0x3c // SIZE 0x3c
// Base vtables are: MxCore -> 0x100dc6b0 -> 0x100dc6e0 -> MxSoundManager // Base vtables are: MxCore -> 0x100dc6b0 -> MxAudioManager -> MxSoundManager
class MxSoundManager : public MxUnknown100dc6e0 class MxSoundManager : public MxAudioManager
{ {
public: public:
MxSoundManager(); MxSoundManager();

View file

@ -1,19 +0,0 @@
#include "mxunknown100dc6e0.h"
// OFFSET: LEGO1 0x100b8d00
MxUnknown100dc6e0::MxUnknown100dc6e0()
{
Init();
}
// OFFSET: LEGO1 0x100b8d90 STUB
MxUnknown100dc6e0::~MxUnknown100dc6e0()
{
// TODO
}
// OFFSET: LEGO1 0x100b8df0
void MxUnknown100dc6e0::Init()
{
this->m_unk2c = 100;
}

View file

@ -1,19 +0,0 @@
#ifndef MXUNKNOWN100DC6E0_H
#define MXUNKNOWN100DC6E0_H
#include "mxmediamanager.h"
// VTABLE 0x100dc6e0
class MxUnknown100dc6e0 : public MxMediaManager
{
public:
MxUnknown100dc6e0();
virtual ~MxUnknown100dc6e0() override;
protected:
void Init();
int m_unk2c;
};
#endif // MXUNKNOWN100DC6E0_H