Isle
Loading...
Searching...
No Matches
MxDSBuffer Class Reference

[AI] Buffer for managing streamed DS (Data Stream) chunks and actions. More...

#include <mxdsbuffer.h>

Inheritance diagram for MxDSBuffer:
Collaboration diagram for MxDSBuffer:

Public Types

enum  Type { e_chunk = 0 , e_allocate = 1 , e_preallocated = 2 , e_unknown = 3 }
 [AI] Buffer memory management type. More...
 

Public Member Functions

 MxDSBuffer ()
 [AI] Constructs a buffer object and initializes all internal pointers and counters. More...
 
 ~MxDSBuffer () override
 [AI] Destructor: Releases memory appropriately based on buffer management mode and asserts no references. More...
 
const char * ClassName () const override
 [AI] Returns the runtime class name for serialization/reflection. More...
 
MxResult AllocateBuffer (MxU32 p_bufferSize, Type p_mode)
 [AI] Allocates a buffer of a given size and memory mode. More...
 
MxResult SetBufferPointer (MxU8 *p_buffer, MxU32 p_size)
 [AI] Sets a buffer pointer and records its size. More...
 
MxResult FUN_100c67b0 (MxStreamController *p_controller, MxDSAction *p_action, MxDSStreamingAction **p_streamingAction)
 [AI] Executes streaming action startup and object creation loop from an initial SI chunk. More...
 
MxResult CreateObject (MxStreamController *p_controller, MxU32 *p_data, MxDSAction *p_action, MxDSStreamingAction **p_streamingAction)
 [AI] Creates a presenter/action object by deserializing a data block. More...
 
MxResult StartPresenterFromAction (MxStreamController *p_controller, MxDSAction *p_action1, MxDSAction *p_action2)
 [AI] Launches a presenter for the given action if not already present. More...
 
MxResult ParseChunk (MxStreamController *p_controller, MxU32 *p_data, MxDSAction *p_action, MxDSStreamingAction **p_streamingAction, MxStreamChunk *p_header)
 [AI] Parses an MxStreamChunk for logical streaming actions, nested chunks, EoS, and splitting. More...
 
MxU8SkipToData ()
 [AI] Scans this buffer forward to the next valid object or chunk and returns a pointer to its start. More...
 
MxU8 ReleaseRef (MxDSChunk *)
 [AI] Decrement the buffer's chunk reference count. More...
 
void AddRef (MxDSChunk *p_chunk)
 [AI] Increment reference count for this buffer (ownership by a chunk). More...
 
MxResult CalcBytesRemaining (MxU8 *p_data)
 [AI] Calculates pending bytes remaining to be streamed, updates buffer state accordingly. More...
 
void FUN_100c6f80 (MxU32 p_writeOffset)
 [AI] Sets the buffer's internal streaming position to the given write offset. More...
 
MxU8FUN_100c6fa0 (MxU8 *p_data)
 [AI] Finds the next chunk boundary in the buffer, starting from an optional pointer. More...
 
MxResult FUN_100c7090 (MxDSBuffer *p_buf)
 [AI] Copies buffer data and selected internal state from another buffer, if space allows. More...
 
MxU8GetBuffer ()
 [AI] Returns a pointer to the managed chunk data buffer. More...
 
undefined4 GetUnknown14 ()
 [AI] Returns the internal value at offset 0x14. More...
 
MxBool HasRef ()
 [AI] Checks whether there are any active references to this buffer. More...
 
MxU16 GetRefCount ()
 [AI] Returns the current buffer reference count. More...
 
Type GetMode ()
 [AI] Returns the current buffer management mode. More...
 
MxU32 GetWriteOffset ()
 [AI] Returns the current buffer write offset (number of bytes with valid data). More...
 
MxU32 GetBytesRemaining ()
 [AI] Returns the number of bytes remaining to stream in this buffer. More...
 
void SetUnknown14 (undefined4 p_unk0x14)
 [AI] Sets the unknown value at offset 0x14. More...
 
void SetUnknown1c (undefined4 p_unk0x1c)
 [AI] Sets the unknown value at offset 0x1c. More...
 
void SetMode (Type p_mode)
 [AI] Sets the buffer memory management mode. More...
 
void SetUnk30 (MxDSStreamingAction *p_unk0x30)
 [AI] Sets the pointer to the currently relevant streaming action for this buffer. More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Static Public Member Functions

static MxCoreReadChunk (MxDSBuffer *p_buffer, MxU32 *p_chunkData, MxU16 p_flags)
 [AI] Reads an SI file object/chunk at given position in a buffer. More...
 
static MxResult Append (MxU8 *p_buffer1, MxU8 *p_buffer2)
 [AI] Appends one chunk/data stream buffer to another, adjusting sizes/headers. More...
 

Detailed Description

[AI] Buffer for managing streamed DS (Data Stream) chunks and actions.

This class manages memory for streaming SI file chunks and objects. It keeps track of memory usage, references, and supports allocation and appending of streamed data. It also serves as a unit to bridge stream controller data with presenters/actions/subscribers and mediates actions related to chunk parsing and presenter startup.

[AI] This buffer handles operations such as allocating memory, tracking offsets/remaining bytes, handling reference counting for chunk retention (i.e., for streaming), parsing complex hierarchical/file block formats (e.g., RIFF/LIST/MxCh/MxOb) from media streams, and managing the lifecycle of streaming actions related to playing back/chunking large media resources.

[]

Definition at line 50 of file mxdsbuffer.h.

Member Enumeration Documentation

◆ Type

[AI] Buffer memory management type.

Enumerator
e_chunk 

[AI] Chunk-managed memory (from Streamer pool).

e_allocate 

[AI] Newly allocated memory with new[].

e_preallocated 

[AI] Preallocated memory passed in from outside.

e_unknown 

[AI] Unknown/other (may be unused or special).

Definition at line 55 of file mxdsbuffer.h.

Constructor & Destructor Documentation

◆ MxDSBuffer()

MxDSBuffer::MxDSBuffer ( )

[AI] Constructs a buffer object and initializes all internal pointers and counters.

Definition at line 17 of file mxdsbuffer.cpp.

◆ ~MxDSBuffer()

MxDSBuffer::~MxDSBuffer ( )
override

[AI] Destructor: Releases memory appropriately based on buffer management mode and asserts no references.

Definition at line 34 of file mxdsbuffer.cpp.

Member Function Documentation

◆ AddRef()

void MxDSBuffer::AddRef ( MxDSChunk p_chunk)

[AI] Increment reference count for this buffer (ownership by a chunk).

Used for split streaming objects, to avoid premature deallocation.

Parameters
p_chunkThe chunk gaining a reference.

Definition at line 408 of file mxdsbuffer.cpp.

◆ AllocateBuffer()

MxResult MxDSBuffer::AllocateBuffer ( MxU32  p_bufferSize,
Type  p_mode 
)

[AI] Allocates a buffer of a given size and memory mode.

Parameters
p_bufferSizeSize, in bytes, to allocate.
p_modeMemory allocation mode.
Returns
SUCCESS if allocation was successful, FAILURE otherwise.

Definition at line 60 of file mxdsbuffer.cpp.

◆ Append()

MxResult MxDSBuffer::Append ( MxU8 p_buffer1,
MxU8 p_buffer2 
)
static

[AI] Appends one chunk/data stream buffer to another, adjusting sizes/headers.

Parameters
p_buffer1Destination buffer. Its length fields are updated.
p_buffer2Source buffer. Payload is copied (header area skipped).
Returns
SUCCESS if append was performed, FAILURE if failed.

Definition at line 509 of file mxdsbuffer.cpp.

◆ CalcBytesRemaining()

MxResult MxDSBuffer::CalcBytesRemaining ( MxU8 p_data)

[AI] Calculates pending bytes remaining to be streamed, updates buffer state accordingly.

Handles chunk offsets/headers and ensures only requested data is marked as remaining. Used to guide further dequeue/transfer operations.

Parameters
p_dataPointer to chunk data in external memory.
Returns
SUCCESS if calculation/recording succeeded, FAILURE otherwise (out of memory, etc.).

Definition at line 417 of file mxdsbuffer.cpp.

◆ ClassName()

const char * MxDSBuffer::ClassName ( ) const
overridevirtual

[AI] Returns the runtime class name for serialization/reflection.

Returns
The constant string "MxDSBuffer".

Reimplemented from MxCore.

◆ CreateObject()

MxResult MxDSBuffer::CreateObject ( MxStreamController p_controller,
MxU32 p_data,
MxDSAction p_action,
MxDSStreamingAction **  p_streamingAction 
)

[AI] Creates a presenter/action object by deserializing a data block.

Depending on the FourCC, dispatches to deserialize a chunk or action object and launches a presenter as appropriate.

Parameters
p_controllerThe stream controller to operate on.
p_dataPointer to start of object data (FourCC-driven).
p_actionThe parent action.
p_streamingActionOutput pointer for streaming action.
Returns
Presenter creation status.

Definition at line 163 of file mxdsbuffer.cpp.

◆ FUN_100c67b0()

MxResult MxDSBuffer::FUN_100c67b0 ( MxStreamController p_controller,
MxDSAction p_action,
MxDSStreamingAction **  p_streamingAction 
)

[AI] Executes streaming action startup and object creation loop from an initial SI chunk.

This method is called for each streaming SI data block, processing it to start and attach presenters/actions as needed. Handles splitting, reference counting, and action list updates.

Parameters
p_controllerThe stream controller managing streaming logic.
p_actionThe parent action.
p_streamingActionOn success, set to created streaming action (output param, may be overwritten/reset).
Returns
SUCCESS on successful operation, FAILURE otherwise.

Definition at line 102 of file mxdsbuffer.cpp.

◆ FUN_100c6f80()

void MxDSBuffer::FUN_100c6f80 ( MxU32  p_writeOffset)

[AI] Sets the buffer's internal streaming position to the given write offset.

Updates internal pointers so next SkipToData()/processing resumes at the given offset.

Parameters
p_writeOffsetThe offset (in bytes) to advance buffer pointers.

Definition at line 450 of file mxdsbuffer.cpp.

◆ FUN_100c6fa0()

MxU8 * MxDSBuffer::FUN_100c6fa0 ( MxU8 p_data)

[AI] Finds the next chunk boundary in the buffer, starting from an optional pointer.

Advances through RIFF/LIST/MxDa/MxOb/MxCh/MxHd blocks as per SI file format to locate the next significant chunk.

Parameters
p_data(Optional) Pointer to start searching from. If nullptr, searches from buffer start.
Returns
Pointer to the next chunk boundary, or nullptr if none found.

Definition at line 459 of file mxdsbuffer.cpp.

◆ FUN_100c7090()

MxResult MxDSBuffer::FUN_100c7090 ( MxDSBuffer p_buf)

[AI] Copies buffer data and selected internal state from another buffer, if space allows.

Used for chunk/A/V buffer transfer.

Parameters
p_bufSource buffer.
Returns
SUCCESS if operation complete, FAILURE otherwise.

Definition at line 495 of file mxdsbuffer.cpp.

◆ GetBuffer()

MxU8 * MxDSBuffer::GetBuffer ( )

[AI] Returns a pointer to the managed chunk data buffer.

Returns
pointer to buffer.

◆ GetBytesRemaining()

MxU32 MxDSBuffer::GetBytesRemaining ( )

[AI] Returns the number of bytes remaining to stream in this buffer.

◆ GetMode()

Type MxDSBuffer::GetMode ( )

[AI] Returns the current buffer management mode.

◆ GetRefCount()

MxU16 MxDSBuffer::GetRefCount ( )

[AI] Returns the current buffer reference count.

◆ GetUnknown14()

undefined4 MxDSBuffer::GetUnknown14 ( )

[AI] Returns the internal value at offset 0x14.

Returns
value of m_unk0x14.

◆ GetWriteOffset()

MxU32 MxDSBuffer::GetWriteOffset ( )

[AI] Returns the current buffer write offset (number of bytes with valid data).

◆ HasRef()

MxBool MxDSBuffer::HasRef ( )

[AI] Checks whether there are any active references to this buffer.

Return values
TRUEIf referenceCount > 0, FALSE if not.

◆ ParseChunk()

MxResult MxDSBuffer::ParseChunk ( MxStreamController p_controller,
MxU32 p_data,
MxDSAction p_action,
MxDSStreamingAction **  p_streamingAction,
MxStreamChunk p_header 
)

[AI] Parses an MxStreamChunk for logical streaming actions, nested chunks, EoS, and splitting.

Handles chunk splitting if necessary, end-of-stream repeats and loop-control, and delegates dispatch to subscribers as appropriate.

Parameters
p_controllerStream controller.
p_dataData pointer.
p_actionParent MxDSAction.
p_streamingAction(Output) streaming action pointer.
p_headerParsed chunk header.
Returns
Status based on chunk and playback logic (could include internal signal).

Definition at line 240 of file mxdsbuffer.cpp.

◆ ReadChunk()

MxCore * MxDSBuffer::ReadChunk ( MxDSBuffer p_buffer,
MxU32 p_chunkData,
MxU16  p_flags 
)
static

[AI] Reads an SI file object/chunk at given position in a buffer.

Depending on the FourCC, deserializes appropriate object type. Normally returns either an MxDSObject or MxDSChunk.

Parameters
p_bufferBuffer to read from.
p_chunkDataPointer to chunk header/FourCC.
p_flagsFlags to drive the deserialization logic.
Returns
Pointer to MxCore-derived object parsed from data (may be MxDSObject or MxDSChunk, or nullptr).

Definition at line 322 of file mxdsbuffer.cpp.

◆ ReleaseRef()

MxU8 MxDSBuffer::ReleaseRef ( MxDSChunk )

[AI] Decrement the buffer's chunk reference count.

Parameters
chunkPointer to the chunk for which to release a reference.
Returns
Always returns 0.

Definition at line 399 of file mxdsbuffer.cpp.

◆ SetBufferPointer()

MxResult MxDSBuffer::SetBufferPointer ( MxU8 p_buffer,
MxU32  p_size 
)

[AI] Sets a buffer pointer and records its size.

Sets this buffer to use externally provided memory.

Parameters
p_bufferPointer to memory.
p_sizeSize of memory block.
Returns
SUCCESS if pointer setup successful.

Definition at line 89 of file mxdsbuffer.cpp.

◆ SetMode()

void MxDSBuffer::SetMode ( Type  p_mode)

[AI] Sets the buffer memory management mode.

Parameters
p_modeThe buffer management type.

◆ SetUnk30()

void MxDSBuffer::SetUnk30 ( MxDSStreamingAction p_unk0x30)

[AI] Sets the pointer to the currently relevant streaming action for this buffer.

Parameters
p_unk0x30Pointer to the streaming action.

◆ SetUnknown14()

void MxDSBuffer::SetUnknown14 ( undefined4  p_unk0x14)

[AI] Sets the unknown value at offset 0x14.

Parameters
p_unk0x14Value to set for m_unk0x14.

◆ SetUnknown1c()

void MxDSBuffer::SetUnknown1c ( undefined4  p_unk0x1c)

[AI] Sets the unknown value at offset 0x1c.

Parameters
p_unk0x1cValue to set for m_unk0x1c.

◆ SkipToData()

MxU8 * MxDSBuffer::SkipToData ( )

[AI] Scans this buffer forward to the next valid object or chunk and returns a pointer to its start.

Advances internal cursor until the next MxOb (object) or MxCh (chunk) in buffer, or nullptr if there is none left.

Returns
Pointer to start of next chunk/object, or nullptr if at end.

Definition at line 352 of file mxdsbuffer.cpp.

◆ StartPresenterFromAction()

MxResult MxDSBuffer::StartPresenterFromAction ( MxStreamController p_controller,
MxDSAction p_action1,
MxDSAction p_action2 
)

[AI] Launches a presenter for the given action if not already present.

Copies required attributes from the original action, registers it, and notifies the controller to set up the action in the stream.

Parameters
p_controllerThe stream controller.
p_action1Source action to copy information from.
p_action2The deserialized action to execute.
Returns
SUCCESS or FAILURE.

Definition at line 201 of file mxdsbuffer.cpp.


The documentation for this class was generated from the following files: