2023-06-29 04:10:08 -04:00
|
|
|
#include "mxcompositemediapresenter.h"
|
|
|
|
|
2023-12-15 10:22:07 -05:00
|
|
|
#include "legosoundmanager.h"
|
2023-12-13 07:53:17 -05:00
|
|
|
#include "legovideomanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "misc.h"
|
2024-03-12 10:23:50 -04:00
|
|
|
#include "mxautolock.h"
|
2023-12-15 10:22:07 -05:00
|
|
|
#include "mxdsmultiaction.h"
|
2023-12-16 10:59:01 -05:00
|
|
|
#include "mxmediapresenter.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2023-12-15 10:22:07 -05:00
|
|
|
#include "mxobjectfactory.h"
|
|
|
|
#include "mxtimer.h"
|
2023-12-13 07:53:17 -05:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxCompositeMediaPresenter, 0x50)
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10073ea0
|
2023-06-29 04:10:08 -04:00
|
|
|
MxCompositeMediaPresenter::MxCompositeMediaPresenter()
|
2023-12-13 07:53:17 -05:00
|
|
|
{
|
|
|
|
m_unk0x4c = 0;
|
2023-12-16 10:59:01 -05:00
|
|
|
m_unk0x4e = FALSE;
|
2024-01-14 16:49:11 -05:00
|
|
|
VideoManager()->RegisterPresenter(*this);
|
2023-12-13 07:53:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10074020
|
|
|
|
MxCompositeMediaPresenter::~MxCompositeMediaPresenter()
|
|
|
|
{
|
2024-01-14 16:49:11 -05:00
|
|
|
VideoManager()->UnregisterPresenter(*this);
|
2023-12-13 07:53:17 -05:00
|
|
|
}
|
|
|
|
|
2023-12-15 10:22:07 -05:00
|
|
|
// FUNCTION: LEGO1 0x10074090
|
2023-12-13 07:53:17 -05:00
|
|
|
MxResult MxCompositeMediaPresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action)
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-12-15 10:22:07 -05:00
|
|
|
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
|
|
|
|
MxDSActionListCursor cursor(actions);
|
|
|
|
MxDSAction* action;
|
|
|
|
|
|
|
|
if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
|
2024-03-01 13:07:07 -05:00
|
|
|
cursor.Head();
|
|
|
|
|
|
|
|
while (cursor.Current(action)) {
|
2023-12-15 10:22:07 -05:00
|
|
|
MxBool success = FALSE;
|
2024-03-01 13:07:07 -05:00
|
|
|
const char* presenterName;
|
|
|
|
MxPresenter* presenter = NULL;
|
|
|
|
|
|
|
|
cursor.Next();
|
2023-12-15 10:22:07 -05:00
|
|
|
|
2024-03-01 13:07:07 -05:00
|
|
|
if (m_action->GetFlags() & MxDSAction::c_looping) {
|
|
|
|
action->SetFlags(action->GetFlags() | MxDSAction::c_looping);
|
|
|
|
}
|
|
|
|
else if (m_action->GetFlags() & MxDSAction::c_bit3) {
|
|
|
|
action->SetFlags(action->GetFlags() | MxDSAction::c_bit3);
|
|
|
|
}
|
2023-12-15 10:22:07 -05:00
|
|
|
|
2024-03-01 13:07:07 -05:00
|
|
|
presenterName = PresenterNameDispatch(*action);
|
|
|
|
presenter = (MxPresenter*) ObjectFactory()->Create(presenterName);
|
2023-12-15 10:22:07 -05:00
|
|
|
|
|
|
|
if (presenter && presenter->AddToManager() == SUCCESS) {
|
|
|
|
presenter->SetCompositePresenter(this);
|
|
|
|
if (presenter->StartAction(p_controller, action) == SUCCESS) {
|
2024-01-17 11:53:53 -05:00
|
|
|
presenter->SetTickleState(e_idle);
|
2023-12-15 10:22:07 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->IsA("MxVideoPresenter")) {
|
2024-01-14 16:49:11 -05:00
|
|
|
VideoManager()->UnregisterPresenter(*presenter);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
|
|
|
else if (presenter->IsA("MxAudioPresenter")) {
|
2024-01-14 16:49:11 -05:00
|
|
|
SoundManager()->UnregisterPresenter(*presenter);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-15 10:22:07 -05:00
|
|
|
|
|
|
|
success = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
action->SetOrigin(this);
|
|
|
|
m_list.push_back(presenter);
|
|
|
|
}
|
2024-02-01 15:42:10 -05:00
|
|
|
else if (presenter) {
|
2023-12-15 10:22:07 -05:00
|
|
|
delete presenter;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-15 10:22:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_compositePresenter) {
|
2024-01-17 11:53:53 -05:00
|
|
|
SetTickleState(e_ready);
|
2023-12-15 10:22:07 -05:00
|
|
|
MxLong time = Timer()->GetTime();
|
|
|
|
m_action->SetUnknown90(time);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2023-12-13 07:53:17 -05:00
|
|
|
}
|
|
|
|
|
2023-12-16 10:59:01 -05:00
|
|
|
// FUNCTION: LEGO1 0x100742e0
|
2023-12-13 07:53:17 -05:00
|
|
|
void MxCompositeMediaPresenter::StartingTickle()
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-12-16 10:59:01 -05:00
|
|
|
|
|
|
|
if (!m_unk0x4e) {
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
2024-01-17 11:53:53 -05:00
|
|
|
if ((*it)->GetCurrentTickleState() < e_streaming) {
|
2023-12-16 10:59:01 -05:00
|
|
|
(*it)->Tickle();
|
|
|
|
|
2024-01-17 11:53:53 -05:00
|
|
|
if ((*it)->GetCurrentTickleState() == e_streaming ||
|
2024-02-01 15:42:10 -05:00
|
|
|
((*it)->GetAction() && (*it)->GetAction()->GetStartTime())) {
|
2023-12-16 10:59:01 -05:00
|
|
|
m_unk0x4c++;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-16 10:59:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_list.size() == m_unk0x4c) {
|
|
|
|
m_unk0x4e = TRUE;
|
|
|
|
m_unk0x4c = 0;
|
|
|
|
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!(*it)->GetAction()->GetStartTime()) {
|
2023-12-16 10:59:01 -05:00
|
|
|
m_unk0x4c++;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-16 10:59:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
2024-01-08 13:07:13 -05:00
|
|
|
if (!(*it)->GetAction()->GetStartTime() && ((MxMediaPresenter*) *it)->CurrentChunk() &&
|
2024-01-17 11:53:53 -05:00
|
|
|
!((*it)->GetAction()->GetFlags() & MxDSAction::c_bit9)) {
|
2023-12-16 10:59:01 -05:00
|
|
|
(*it)->Tickle();
|
2024-01-17 11:53:53 -05:00
|
|
|
(*it)->GetAction()->SetFlags((*it)->GetAction()->GetFlags() | MxDSAction::c_bit9);
|
2023-12-16 10:59:01 -05:00
|
|
|
m_unk0x4c--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_unk0x4c) {
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_streaming);
|
2023-12-16 10:59:01 -05:00
|
|
|
MxLong time = Timer()->GetTime();
|
|
|
|
m_action->SetUnknown90(time);
|
|
|
|
}
|
|
|
|
}
|
2023-12-13 07:53:17 -05:00
|
|
|
}
|
|
|
|
|
2023-12-16 10:59:01 -05:00
|
|
|
// FUNCTION: LEGO1 0x10074470
|
2023-12-13 07:53:17 -05:00
|
|
|
MxResult MxCompositeMediaPresenter::Tickle()
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-12-16 10:59:01 -05:00
|
|
|
|
|
|
|
switch (m_currentTickleState) {
|
2024-01-17 11:53:53 -05:00
|
|
|
case e_ready:
|
|
|
|
ProgressTickleState(e_starting);
|
|
|
|
case e_starting:
|
2023-12-16 10:59:01 -05:00
|
|
|
StartingTickle();
|
|
|
|
break;
|
2024-01-17 11:53:53 -05:00
|
|
|
case e_streaming:
|
|
|
|
case e_repeating:
|
|
|
|
case e_unk5:
|
|
|
|
case e_done: {
|
2024-02-01 15:42:10 -05:00
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
2023-12-16 10:59:01 -05:00
|
|
|
(*it)->Tickle();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-16 10:59:01 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-12-13 07:53:17 -05:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-12-16 10:59:01 -05:00
|
|
|
// FUNCTION: LEGO1 0x10074540
|
2023-12-13 07:53:17 -05:00
|
|
|
MxResult MxCompositeMediaPresenter::PutData()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-12-16 10:59:01 -05:00
|
|
|
|
2024-01-17 11:53:53 -05:00
|
|
|
if (m_currentTickleState >= e_streaming && m_currentTickleState <= e_done) {
|
2024-02-01 15:42:10 -05:00
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
2023-12-16 10:59:01 -05:00
|
|
|
(*it)->PutData();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-16 10:59:01 -05:00
|
|
|
}
|
|
|
|
|
2023-12-13 07:53:17 -05:00
|
|
|
return SUCCESS;
|
2023-10-25 14:51:59 -04:00
|
|
|
}
|