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;
|
|
|
|
}
|
2024-02-01 15:42:10 -05:00
|
|
|
else {
|
2023-10-24 19:38:27 -04:00
|
|
|
TickleManager()->UnregisterClient(this);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-13 12:43:45 -04:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!p_fromDestructor) {
|
2023-10-24 19:38:27 -04:00
|
|
|
MxMediaManager::Destroy();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
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
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!this->m_thread || this->m_thread->Start(0, 0) != SUCCESS) {
|
2023-10-24 19:38:27 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
2024-02-01 15:42:10 -05:00
|
|
|
else {
|
2023-10-24 19:38:27 -04:00
|
|
|
TickleManager()->RegisterClient(this, p_frequencyMS);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
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:
|
2024-02-01 15:42:10 -05:00
|
|
|
if (status != SUCCESS) {
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-07 17:30:05 -04:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (locked) {
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_criticalSection.Leave();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
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
|
|
|
}
|