2023-06-29 04:10:08 -04:00
|
|
|
#include "mxcompositemediapresenter.h"
|
|
|
|
|
2023-12-13 07:53:17 -05:00
|
|
|
#include "legoomni.h"
|
2023-12-15 10:22:07 -05:00
|
|
|
#include "legosoundmanager.h"
|
2023-12-13 07:53:17 -05:00
|
|
|
#include "legovideomanager.h"
|
2023-12-15 10:22:07 -05:00
|
|
|
#include "mxautolocker.h"
|
|
|
|
#include "mxdsmultiaction.h"
|
2023-12-16 10:59:01 -05:00
|
|
|
#include "mxmediapresenter.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;
|
2023-12-13 07:53:17 -05:00
|
|
|
VideoManager()->AddPresenter(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10074020
|
|
|
|
MxCompositeMediaPresenter::~MxCompositeMediaPresenter()
|
|
|
|
{
|
|
|
|
VideoManager()->RemovePresenter(*this);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2023-12-15 10:22:07 -05:00
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
|
|
|
|
MxDSActionListCursor cursor(actions);
|
|
|
|
MxDSAction* action;
|
|
|
|
|
|
|
|
if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
|
|
|
|
// The usual cursor.Next() loop doesn't match here, even though
|
|
|
|
// the logic is the same. It does match when "deconstructed" into
|
|
|
|
// the following Head(), Current() and NextFragment() calls,
|
|
|
|
// but this seems unlikely to be the original code.
|
|
|
|
// The alpha debug build also uses Next().
|
|
|
|
// cursor.Head();
|
|
|
|
// while (cursor.Current(action)) {
|
|
|
|
// cursor.NextFragment();
|
|
|
|
while (cursor.Next(action)) {
|
|
|
|
MxBool success = FALSE;
|
|
|
|
|
|
|
|
action->CopyFlags(m_action->GetFlags());
|
|
|
|
|
|
|
|
const char* presenterName = PresenterNameDispatch(*action);
|
|
|
|
MxPresenter* presenter = (MxPresenter*) ObjectFactory()->Create(presenterName);
|
|
|
|
|
|
|
|
if (presenter && presenter->AddToManager() == SUCCESS) {
|
|
|
|
presenter->SetCompositePresenter(this);
|
|
|
|
if (presenter->StartAction(p_controller, action) == SUCCESS) {
|
|
|
|
presenter->SetTickleState(TickleState_Idle);
|
|
|
|
|
|
|
|
if (presenter->IsA("MxVideoPresenter"))
|
|
|
|
VideoManager()->RemovePresenter(*presenter);
|
|
|
|
else if (presenter->IsA("MxAudioPresenter"))
|
|
|
|
SoundManager()->RemovePresenter(*presenter);
|
|
|
|
|
|
|
|
success = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
action->SetOrigin(this);
|
|
|
|
m_list.push_back(presenter);
|
|
|
|
}
|
|
|
|
else if (presenter)
|
|
|
|
delete presenter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_compositePresenter) {
|
|
|
|
SetTickleState(TickleState_Ready);
|
|
|
|
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()
|
|
|
|
{
|
2023-12-16 10:59:01 -05:00
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
if (!m_unk0x4e) {
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
if ((*it)->GetCurrentTickleState() < TickleState_Streaming) {
|
|
|
|
(*it)->Tickle();
|
|
|
|
|
|
|
|
if ((*it)->GetCurrentTickleState() == TickleState_Streaming ||
|
|
|
|
((*it)->GetAction() && (*it)->GetAction()->GetStartTime()))
|
|
|
|
m_unk0x4c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_list.size() == m_unk0x4c) {
|
|
|
|
m_unk0x4e = TRUE;
|
|
|
|
m_unk0x4c = 0;
|
|
|
|
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
if (!(*it)->GetAction()->GetStartTime())
|
|
|
|
m_unk0x4c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
if (!(*it)->GetAction()->GetStartTime() && ((MxMediaPresenter*) *it)->FUN_100b5650() &&
|
|
|
|
!((*it)->GetAction()->GetFlags() & MxDSAction::Flag_Bit9)) {
|
|
|
|
(*it)->Tickle();
|
|
|
|
(*it)->GetAction()->SetFlags((*it)->GetAction()->GetFlags() | MxDSAction::Flag_Bit9);
|
|
|
|
m_unk0x4c--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_unk0x4c) {
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Streaming;
|
|
|
|
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()
|
|
|
|
{
|
2023-12-16 10:59:01 -05:00
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
switch (m_currentTickleState) {
|
|
|
|
case TickleState_Ready:
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Starting;
|
|
|
|
case TickleState_Starting:
|
|
|
|
StartingTickle();
|
|
|
|
break;
|
|
|
|
case TickleState_Streaming:
|
|
|
|
case TickleState_Repeating:
|
|
|
|
case TickleState_unk5:
|
|
|
|
case TickleState_Done: {
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++)
|
|
|
|
(*it)->Tickle();
|
|
|
|
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
|
|
|
{
|
2023-12-16 10:59:01 -05:00
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
if (m_currentTickleState >= TickleState_Streaming && m_currentTickleState <= TickleState_Done) {
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++)
|
|
|
|
(*it)->PutData();
|
|
|
|
}
|
|
|
|
|
2023-12-13 07:53:17 -05:00
|
|
|
return SUCCESS;
|
2023-10-25 14:51:59 -04:00
|
|
|
}
|