2023-08-28 06:01:45 -04:00
|
|
|
#include "mxmediamanager.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
#include "decomp.h"
|
2024-03-12 10:23:50 -04:00
|
|
|
#include "mxautolock.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxomni.h"
|
2023-09-17 06:38:50 -04:00
|
|
|
#include "mxpresenter.h"
|
2023-10-07 17:30:05 -04:00
|
|
|
#include "mxticklemanager.h"
|
2023-08-28 06:01:45 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxMediaManager, 0x2c);
|
2023-12-20 20:09:05 -05:00
|
|
|
DECOMP_SIZE_ASSERT(MxPresenterList, 0x18);
|
|
|
|
DECOMP_SIZE_ASSERT(MxPresenterListCursor, 0x10);
|
2023-08-28 06:01:45 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b84c0
|
2023-08-28 06:01:45 -04:00
|
|
|
MxMediaManager::MxMediaManager()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-08-28 06:01:45 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b8560
|
2023-08-28 06:01:45 -04:00
|
|
|
MxMediaManager::~MxMediaManager()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy();
|
2023-08-28 06:01:45 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b85d0
|
2023-08-28 06:01:45 -04:00
|
|
|
MxResult MxMediaManager::Init()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_presenters = NULL;
|
|
|
|
this->m_thread = NULL;
|
|
|
|
return SUCCESS;
|
2023-08-28 06:01:45 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b85e0
|
2023-09-17 00:18:56 -04:00
|
|
|
MxResult MxMediaManager::InitPresenters()
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-09-17 00:18:56 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_presenters = new MxPresenterList;
|
2023-09-17 00:18:56 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
if (!this->m_presenters) {
|
|
|
|
this->Destroy();
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2023-09-17 00:18:56 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return SUCCESS;
|
2023-09-17 00:18:56 -04:00
|
|
|
}
|
2023-09-17 06:38:50 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b8710
|
2023-09-17 06:38:50 -04:00
|
|
|
void MxMediaManager::Destroy()
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-09-17 06:38:50 -04:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (this->m_presenters) {
|
2023-10-24 19:38:27 -04:00
|
|
|
delete this->m_presenters;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-07 17:30:05 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-09-17 06:38:50 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b8790
|
2023-11-21 03:44:45 -05:00
|
|
|
MxResult MxMediaManager::Tickle()
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-11-21 03:44:45 -05:00
|
|
|
MxPresenter* presenter;
|
|
|
|
MxPresenterListCursor cursor(this->m_presenters);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
while (cursor.Next(presenter)) {
|
2023-11-21 03:44:45 -05:00
|
|
|
presenter->Tickle();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
|
|
|
|
cursor.Reset();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
while (cursor.Next(presenter)) {
|
2023-11-21 03:44:45 -05:00
|
|
|
presenter->PutData();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b88c0
|
2024-01-14 16:49:11 -05:00
|
|
|
void MxMediaManager::RegisterPresenter(MxPresenter& p_presenter)
|
2023-09-17 06:38:50 -04:00
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-09-17 06:38:50 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_presenters->Append(&p_presenter);
|
2023-09-17 06:38:50 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b8980
|
2024-01-14 16:49:11 -05:00
|
|
|
void MxMediaManager::UnregisterPresenter(MxPresenter& p_presenter)
|
2023-09-17 06:38:50 -04:00
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-10-24 19:38:27 -04:00
|
|
|
MxPresenterListCursor cursor(this->m_presenters);
|
2023-09-17 06:38:50 -04:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find(&p_presenter)) {
|
2023-10-24 19:38:27 -04:00
|
|
|
cursor.Detach();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-09-17 06:38:50 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b8ac0
|
2023-09-17 06:38:50 -04:00
|
|
|
void MxMediaManager::StopPresenters()
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-10-24 19:38:27 -04:00
|
|
|
MxPresenter* presenter;
|
|
|
|
MxPresenterListCursor cursor(this->m_presenters);
|
2023-09-17 06:38:50 -04:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
while (cursor.Next(presenter)) {
|
2023-10-24 19:38:27 -04:00
|
|
|
presenter->EndAction();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-25 14:51:59 -04:00
|
|
|
}
|