Isle
Loading...
Searching...
No Matches
legoloadcachesoundpresenter.cpp
Go to the documentation of this file.
2
4#include "legocachsound.h"
5#include "legosoundmanager.h"
6#include "misc.h"
7#include "mxdssound.h"
8#include "mxdssubscriber.h"
9#include "mxstreamchunk.h"
10#include "mxwavepresenter.h"
11
13
14// FUNCTION: LEGO1 0x10018340
16{
17 Init();
18}
19
20// FUNCTION: LEGO1 0x10018480
22{
24}
25
26// FUNCTION: LEGO1 0x100184e0
27void LegoLoadCacheSoundPresenter::Init()
28{
29 m_data = NULL;
30 m_dataSize = 0;
31 m_unk0x7c = FALSE;
32}
33
34// FUNCTION: LEGO1 0x100184f0
36{
37 delete[] m_data;
38 MxWavePresenter::Destroy(p_fromDestructor);
39}
40
41// FUNCTION: LEGO1 0x10018510
42// FUNCTION: BETA10 0x1008c305
44{
45 MxStreamChunk* chunk = NextChunk();
46
47 if (chunk) {
48 WaveFormat* header = (WaveFormat*) chunk->GetData();
49 m_dataSize = 0;
50
51 MxU8* data = new MxU8[header->m_dataSize];
52 m_data = data;
53 m_pData = data;
54
55 m_cacheSound = new LegoCacheSound();
56 m_pcmWaveFormat = header->m_pcmWaveFormat;
57
60 }
61}
62
63// FUNCTION: LEGO1 0x100185f0
64// FUNCTION: BETA10 0x1008c48f
66{
67 MxStreamChunk* chunk = NextChunk();
68
69 if (chunk) {
71 m_cacheSound->Create(
72 &m_pcmWaveFormat,
73 ((MxDSSound*) m_action)->GetMediaSrcPath(),
75 m_data + 2,
76 m_dataSize - 2
77 );
79 }
80 else {
81 memcpy(m_pData, chunk->GetData(), chunk->GetLength());
82 m_dataSize += chunk->GetLength();
83 m_pData += chunk->GetLength();
84 }
85
87 }
88}
89
90// FUNCTION: LEGO1 0x100186f0
92{
93 if (m_unk0x7c) {
94 EndAction();
95 }
96}
97
98// FUNCTION: LEGO1 0x10018700
100{
102
104 m_cacheSound = SoundManager()->GetCacheSoundManager()->ManageSoundEntry(m_cacheSound);
105 m_unk0x7c = TRUE;
106 }
107
109 return SUCCESS;
110}
LegoCacheSound * ManageSoundEntry(LegoCacheSound *p_sound)
[AI] Manages a sound entry.
Sound cache object managing DirectSound buffers and 3D positioning for preloaded sound data.
Definition: legocachsound.h:17
virtual MxResult Create(LPPCMWAVEFORMAT p_pwfx, MxString p_mediaSrcPath, MxS32 p_volume, MxU8 *p_data, MxU32 p_dataSize)
Creates the sound object with given audio format, source path, volume, and initializes DirectSound bu...
Derived presenter class used for loading and creating cached sound objects from streamed audio data.
~LegoLoadCacheSoundPresenter() override
Destructor.
void DoneTickle() override
Called when the presenter enters the DoneTickle state.
void ReadyTickle() override
Called when the presenter enters the ReadyTickle state.
MxResult PutData() override
Called to commit prepared data to the cache manager.
void StreamingTickle() override
Called during the StreamingTickle state.
LegoCacheSoundManager * GetCacheSoundManager()
[AI] Returns the cache sound manager used to cache and reuse sound effects.
virtual MxS32 GetVolume()
[AI] Returns the current runtime audio volume for this presenter (0-100).
void Enter()
[AI] Acquires/gains entry to the critical section or mutex, blocking if not available.
void Leave()
[AI] Releases/leaves the critical section or mutex.
MxU32 GetLength()
[AI] Returns the length in bytes of the data payload. [AI]
Definition: mxdschunk.h:105
MxU8 * GetData()
[AI] Returns a pointer to the start of the data payload. [AI]
Definition: mxdschunk.h:108
MxU16 GetChunkFlags()
[AI] Returns the chunk's flag bitfield. [AI]
Definition: mxdschunk.h:96
[AI] Represents a sound action extracted from an SI script and used in the data-driven action system.
Definition: mxdssound.h:14
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
MxStreamChunk * NextChunk()
[AI] Returns the next data chunk in the stream, removing it from the stream queue.
void Destroy() override
[AI] Cleans up internal resources and resets the presenter to an uninitialized state.
MxDSSubscriber * m_subscriber
[AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter.
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
Definition: mxpresenter.h:72
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
Definition: mxpresenter.h:199
@ e_done
[AI] Completed processing the current action.
Definition: mxpresenter.h:30
@ e_streaming
[AI] Streaming or rendering actively.
Definition: mxpresenter.h:27
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
Definition: mxstreamchunk.h:19
void EndAction() override
[AI] Ends the media playback action, releasing all resources, notifying listeners if necessary.
void Destroy() override
[AI] Explicit resource release.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
#define DS_CHUNK_END_OF_STREAM
[AI] Flag bit indicating this chunk is the last in its stream.
Definition: mxdschunk.h:14
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
[AI] Holds WAVE PCM format info for DirectSound buffer creation and streaming.
MxU32 m_dataSize
[AI] Size of data buffer for the wave data.
PCMWAVEFORMAT m_pcmWaveFormat
[AI] PCM format struct containing standard Windows WAVE format fields.