Implement MxVideoManager::Destroy / destructor (#207)

* MxVideoManager::Destroy / destructor

* Consistency

* Add missing override
This commit is contained in:
Christian Semmler 2023-10-14 14:46:00 -04:00 committed by GitHub
parent f062543f87
commit 5ddfaab9e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 6 deletions

View file

@ -1,6 +1,8 @@
#include "mxvideomanager.h" #include "mxvideomanager.h"
#include "mxautolocker.h" #include "mxautolocker.h"
#include "mxpresenter.h" #include "mxpresenter.h"
#include "mxticklemanager.h"
#include "legoomni.h"
// OFFSET: LEGO1 0x100be1f0 // OFFSET: LEGO1 0x100be1f0
MxVideoManager::MxVideoManager() MxVideoManager::MxVideoManager()
@ -8,10 +10,10 @@ MxVideoManager::MxVideoManager()
Init(); Init();
} }
// OFFSET: LEGO1 0x100be2a0 STUB // OFFSET: LEGO1 0x100be2a0
MxVideoManager::~MxVideoManager() MxVideoManager::~MxVideoManager()
{ {
// TODO Destroy(TRUE);
} }
// OFFSET: LEGO1 0x100bea90 // OFFSET: LEGO1 0x100bea90
@ -50,6 +52,41 @@ MxResult MxVideoManager::Init()
return SUCCESS; return SUCCESS;
} }
// OFFSET: LEGO1 0x100be340
void MxVideoManager::Destroy(MxBool p_fromDestructor)
{
if (m_thread) {
m_thread->Terminate();
delete m_thread;
}
else
TickleManager()->UnregisterClient(this);
m_criticalSection.Enter();
if (m_displaySurface)
delete m_displaySurface;
if (m_region)
delete m_region;
if (m_videoParam.GetPalette())
delete m_videoParam.GetPalette();
if (m_unk60) {
if (m_pDirectDraw)
m_pDirectDraw->Release();
if (m_pDDSurface)
m_pDDSurface->Release();
}
Init();
m_criticalSection.Leave();
if (!p_fromDestructor)
MxMediaManager::Destroy();
}
// OFFSET: LEGO1 0x100be440 // OFFSET: LEGO1 0x100be440
void MxVideoManager::SortPresenterList() void MxVideoManager::SortPresenterList()
{ {
@ -89,6 +126,12 @@ void MxVideoManager::UpdateRegion()
// TODO // TODO
} }
// OFFSET: LEGO1 0x100bea50
void MxVideoManager::Destroy()
{
Destroy(FALSE);
}
// OFFSET: LEGO1 0x100bea60 STUB // OFFSET: LEGO1 0x100bea60 STUB
void MxVideoManager::InvalidateRect(MxRect32 &p_rect) void MxVideoManager::InvalidateRect(MxRect32 &p_rect)
{ {

View file

@ -11,9 +11,10 @@
class MxVideoManager : public MxMediaManager class MxVideoManager : public MxMediaManager
{ {
public: public:
virtual ~MxVideoManager(); virtual ~MxVideoManager() override;
virtual MxResult Tickle() override; // vtable+0x8 virtual MxResult Tickle() override; // vtable+0x8
virtual void Destroy() override; // vtable+0x18
virtual void vtable0x28(); // vtable+0x28 (TODO ARGUMENTS) virtual void vtable0x28(); // vtable+0x28 (TODO ARGUMENTS)
virtual MxResult vtable0x2c(MxVideoParam& p_videoParam, undefined4 p_unknown1, MxU8 p_unknown2); // vtable+0x2c virtual MxResult vtable0x2c(MxVideoParam& p_videoParam, undefined4 p_unknown1, MxU8 p_unknown2); // vtable+0x2c
@ -23,6 +24,7 @@ class MxVideoManager : public MxMediaManager
MxVideoManager(); MxVideoManager();
MxResult Init(); MxResult Init();
void Destroy(MxBool p_fromDestructor);
void SortPresenterList(); void SortPresenterList();
void UpdateRegion(); void UpdateRegion();

View file

@ -65,11 +65,11 @@ MxVideoParam &MxVideoParam::operator=(const MxVideoParam &p_videoParam)
void MxVideoParam::SetDeviceName(char *id) void MxVideoParam::SetDeviceName(char *id)
{ {
if (this->m_deviceId != 0) if (this->m_deviceId != 0)
free(this->m_deviceId); delete[] this->m_deviceId;
if (id != 0) if (id != 0)
{ {
this->m_deviceId = (char *)malloc(strlen(id) + 1); this->m_deviceId = new char[strlen(id) + 1];
if (this->m_deviceId != 0) { if (this->m_deviceId != 0) {
strcpy(this->m_deviceId, id); strcpy(this->m_deviceId, id);
@ -84,5 +84,5 @@ void MxVideoParam::SetDeviceName(char *id)
MxVideoParam::~MxVideoParam() MxVideoParam::~MxVideoParam()
{ {
if (this->m_deviceId != 0) if (this->m_deviceId != 0)
free(this->m_deviceId); delete[] this->m_deviceId;
} }