Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::Audio::COnlineMemoryStream Class Reference

A thread-safe dynamic memory stream for online data (e.g. voice chat or network audio). New data can be uploaded at runtime while the cursor reads from it. More...

#include <Stream/COnlineMemoryStream.h>

Inheritance diagram for Skylicht::Audio::COnlineMemoryStream:
Skylicht::Audio::IStream

Public Member Functions

virtual IStreamCursorcreateCursor ()
 Create a new online cursor.
unsigned char * getDataBuffer ()
 Get pointer to the underlying buffer.
int getDataBufferSize ()
 Get total size of available data.
virtual void uploadData (unsigned char *buffer, int size)
 Append new data to the stream. Thread-safe.
IMutexgetMutex ()
 Get the internal synchronization mutex.
void setFullData (bool b)
 Mark the stream as finished (no more data will be uploaded).
bool isFullData ()
 Check if the stream is marked as complete.
bool isStopStream ()
 Check if the stream has been stopped.
void setStopStream (bool b)
 Stop the stream.
virtual void trim (int position)
 Remove data before the specified position.
virtual void stopStream ()
 Stop the stream and clear all buffers.
Public Member Functions inherited from Skylicht::Audio::IStream
virtual void grab ()
 Increment reference count.
virtual bool drop ()
 Decrement reference count and delete if zero.
int getSampleRate ()
 Get expected sample rate (for recorder/procedural streams).
int getChannels ()
 Get number of channels (for recorder/procedural streams).
void setStreamAudio (int sampleRate, int channels)
 Set stream audio properties.

Protected Attributes

unsigned char * m_buffer
int m_size
int m_allocSize
IMutexm_mutex
bool m_fullDataStream
bool m_stopStream
Protected Attributes inherited from Skylicht::Audio::IStream
int m_referenceCount
int m_sampleRate
int m_channels

Detailed Description

A thread-safe dynamic memory stream for online data (e.g. voice chat or network audio). New data can be uploaded at runtime while the cursor reads from it.

Member Function Documentation

◆ createCursor()

virtual IStreamCursor * Skylicht::Audio::COnlineMemoryStream::createCursor ( )
virtual

Create a new online cursor.

Returns
Pointer to COnlineMemoryStreamCursor

Implements Skylicht::Audio::IStream.

◆ getDataBuffer()

unsigned char * Skylicht::Audio::COnlineMemoryStream::getDataBuffer ( )

Get pointer to the underlying buffer.

Note
Must lock the stream mutex before access.
Returns
Pointer to unsigned char buffer

◆ getDataBufferSize()

int Skylicht::Audio::COnlineMemoryStream::getDataBufferSize ( )

Get total size of available data.

Note
Must lock the stream mutex before access.
Returns
Size in bytes

◆ getMutex()

IMutex * Skylicht::Audio::COnlineMemoryStream::getMutex ( )
inline

Get the internal synchronization mutex.

Returns
Pointer to IMutex

◆ isFullData()

bool Skylicht::Audio::COnlineMemoryStream::isFullData ( )
inline

Check if the stream is marked as complete.

Returns
True if complete

◆ isStopStream()

bool Skylicht::Audio::COnlineMemoryStream::isStopStream ( )
inline

Check if the stream has been stopped.

Returns
True if stopped

◆ setFullData()

void Skylicht::Audio::COnlineMemoryStream::setFullData ( bool b)
inline

Mark the stream as finished (no more data will be uploaded).

Parameters
bTrue if the stream is complete

◆ setStopStream()

void Skylicht::Audio::COnlineMemoryStream::setStopStream ( bool b)
inline

Stop the stream.

Parameters
bTrue to stop

◆ stopStream()

virtual void Skylicht::Audio::COnlineMemoryStream::stopStream ( )
virtual

Stop the stream and clear all buffers.

Reimplemented from Skylicht::Audio::IStream.

◆ trim()

virtual void Skylicht::Audio::COnlineMemoryStream::trim ( int position)
virtual

Remove data before the specified position.

Parameters
positionNumber of bytes to trim from the start

◆ uploadData()

virtual void Skylicht::Audio::COnlineMemoryStream::uploadData ( unsigned char * buffer,
int size )
virtual

Append new data to the stream. Thread-safe.

Parameters
bufferData to upload
sizeSize in bytes

Reimplemented from Skylicht::Audio::IStream.


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