Implement/match LegoCacheSound::Create and LegoLoadCacheSoundPresenter::StreamingTickle (#986)

* Implement/match LegoCacheSound::Create

* Naming

* Fix naming

* Fix parens
This commit is contained in:
Christian Semmler
2024-06-01 17:29:37 -04:00
committed by GitHub
parent 1423eb56fc
commit 03ffb9c5de
9 changed files with 165 additions and 54 deletions

View File

@@ -4,6 +4,7 @@
#include "legocachsound.h"
#include "legosoundmanager.h"
#include "misc.h"
#include "mxdssound.h"
#include "mxdssubscriber.h"
#include "mxstreamchunk.h"
#include "mxwavepresenter.h"
@@ -25,50 +26,71 @@ LegoLoadCacheSoundPresenter::~LegoLoadCacheSoundPresenter()
// FUNCTION: LEGO1 0x100184e0
void LegoLoadCacheSoundPresenter::Init()
{
this->m_unk0x70 = NULL;
this->m_unk0x78 = 0;
this->m_unk0x7c = 0;
m_data = NULL;
m_dataSize = 0;
m_unk0x7c = FALSE;
}
// FUNCTION: LEGO1 0x100184f0
void LegoLoadCacheSoundPresenter::Destroy(MxBool p_fromDestructor)
{
delete[] this->m_unk0x70;
delete[] m_data;
MxWavePresenter::Destroy(p_fromDestructor);
}
// FUNCTION: LEGO1 0x10018510
// FUNCTION: BETA10 0x1008c305
void LegoLoadCacheSoundPresenter::ReadyTickle()
{
MxStreamChunk* chunk = NextChunk();
if (chunk) {
WaveFormat* header = (WaveFormat*) chunk->GetData();
m_unk0x78 = 0;
m_dataSize = 0;
MxU8* data = new MxU8[header->m_dataSize];
m_unk0x70 = data;
m_unk0x74 = data;
m_data = data;
m_pData = data;
m_cacheSound = new LegoCacheSound;
memcpy(&m_pcmWaveFormat, &header->m_pcmWaveFormat, sizeof(m_pcmWaveFormat));
m_cacheSound = new LegoCacheSound();
m_pcmWaveFormat = header->m_pcmWaveFormat;
m_subscriber->FreeDataChunk(chunk);
ProgressTickleState(e_streaming);
}
}
// STUB: LEGO1 0x100185f0
// FUNCTION: LEGO1 0x100185f0
// FUNCTION: BETA10 0x1008c48f
void LegoLoadCacheSoundPresenter::StreamingTickle()
{
// TODO
EndAction();
MxStreamChunk* chunk = NextChunk();
if (chunk) {
if (chunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) {
m_cacheSound->Create(
&m_pcmWaveFormat,
((MxDSSound*) m_action)->GetMediaSrcPath(),
((MxDSSound*) m_action)->GetVolume(),
m_data + 2,
m_dataSize - 2
);
ProgressTickleState(e_done);
}
else {
memcpy(m_pData, chunk->GetData(), chunk->GetLength());
m_dataSize += chunk->GetLength();
m_pData += chunk->GetLength();
}
m_subscriber->FreeDataChunk(chunk);
}
}
// FUNCTION: LEGO1 0x100186f0
void LegoLoadCacheSoundPresenter::DoneTickle()
{
if (m_unk0x7c != 0) {
if (m_unk0x7c) {
EndAction();
}
}
@@ -80,7 +102,7 @@ MxResult LegoLoadCacheSoundPresenter::PutData()
if (m_currentTickleState == e_done) {
m_cacheSound = SoundManager()->GetCacheSoundManager()->ManageSoundEntry(m_cacheSound);
m_unk0x7c = 1;
m_unk0x7c = TRUE;
}
m_criticalSection.Leave();