2023-06-29 04:10:08 -04:00
|
|
|
#include "mxeventmanager.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2023-10-07 17:30:05 -04:00
|
|
|
#include "mxcriticalsection.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxomni.h"
|
2023-10-07 17:30:05 -04:00
|
|
|
#include "mxthread.h"
|
|
|
|
#include "mxticklemanager.h"
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c0360
|
2023-06-29 04:10:08 -04:00
|
|
|
MxEventManager::MxEventManager()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c03f0
|
2023-06-29 04:10:08 -04:00
|
|
|
MxEventManager::~MxEventManager()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy(TRUE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-08-03 19:43:36 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c0450
|
2023-08-03 19:43:36 -04:00
|
|
|
void MxEventManager::Init()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
// This is intentionally left blank
|
2023-10-07 14:05:45 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c0460
|
2023-10-13 12:43:45 -04:00
|
|
|
void MxEventManager::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
if (m_thread != NULL) {
|
|
|
|
m_thread->Terminate();
|
|
|
|
delete m_thread;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TickleManager()->UnregisterClient(this);
|
2023-10-13 12:43:45 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
if (!p_fromDestructor)
|
|
|
|
MxMediaManager::Destroy();
|
2023-10-13 12:43:45 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c04a0
|
2023-10-14 20:49:07 -04:00
|
|
|
MxResult MxEventManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
|
2023-10-07 14:05:45 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult status = FAILURE;
|
|
|
|
MxBool locked = FALSE;
|
2023-10-07 17:30:05 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult result = MxMediaManager::InitPresenters();
|
|
|
|
if (result == SUCCESS) {
|
|
|
|
if (p_createThread) {
|
|
|
|
this->m_criticalSection.Enter();
|
|
|
|
locked = TRUE;
|
|
|
|
this->m_thread = new MxTickleThread(this, p_frequencyMS);
|
2023-10-07 17:30:05 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
if (!this->m_thread || this->m_thread->Start(0, 0) != SUCCESS)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TickleManager()->RegisterClient(this, p_frequencyMS);
|
2023-10-14 20:49:07 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
status = SUCCESS;
|
|
|
|
}
|
2023-10-07 17:30:05 -04:00
|
|
|
|
2023-10-14 20:49:07 -04:00
|
|
|
done:
|
2023-10-24 19:38:27 -04:00
|
|
|
if (status != SUCCESS)
|
|
|
|
Destroy();
|
2023-10-07 17:30:05 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
if (locked)
|
|
|
|
this->m_criticalSection.Leave();
|
2023-10-07 17:30:05 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return status;
|
2023-10-07 14:05:45 -04:00
|
|
|
}
|
2023-10-13 12:43:45 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c0590
|
2023-10-13 12:43:45 -04:00
|
|
|
void MxEventManager::Destroy()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy(FALSE);
|
2023-10-13 12:43:45 -04:00
|
|
|
}
|