PCM Sample Buffers


Data Structures

struct  MLO_SampleFormat
 Information about the encoding, memory layout, sample rate and number of channels of the PCM audio data represented by an MLO_SampleBuffer object. More...

Typedefs

typedef MLO_SampleBuffer MLO_SampleBuffer
 MLO_SampleBuffer object.

Enumerations

enum  MLO_SampleType { MLO_SAMPLE_TYPE_INTERLACED_SIGNED = 0 }
 Sample type indicating the way PCM sample values are encoded and layed out in memory. More...

Functions

MLO_Result MLO_SampleBuffer_Create (MLO_Size size, MLO_SampleBuffer **buffer)
 Create a new instance of an MLO_SampleBuffer object.
MLO_Result MLO_SampleBuffer_Destroy (MLO_SampleBuffer *self)
 Destroy an MLO_SampleBuffer object and free the resources associated with it.
const void * MLO_SampleBuffer_GetSamples (const MLO_SampleBuffer *self)
 Return a (const) pointer to the memory buffer containing the PCM audio samples encapsulated by an MLO_SampleBuffer object.
void * MLO_SampleBuffer_UseSamples (MLO_SampleBuffer *self)
 Return a pointer to the memory buffer containing the PCM audio samples encapsulated by an MLO_SampleBuffer object.
MLO_Cardinal MLO_SampleBuffer_GetSampleCount (const MLO_SampleBuffer *self)
 Return the number of audio samples encapsulated in a MLO_SampleBuffer object.
MLO_Result MLO_SampleBuffer_SetSampleCount (MLO_SampleBuffer *self, MLO_Cardinal sample_count)
 Set the number of audio samples encapsulated in a MLO_SampleBuffer object.
MLO_Size MLO_SampleBuffer_GetSize (const MLO_SampleBuffer *self)
 Return the size of the buffer encapsulated in a MLO_SampleBuffer object.
const MLO_SampleFormatMLO_SampleBuffer_GetFormat (const MLO_SampleBuffer *self)
 Return the format of the PCM samples encapsulated by an MLO_SampleBuffer object.
void MLO_SampleBuffer_SetFormat (MLO_SampleBuffer *self, const MLO_SampleFormat *format)
 Sets the format of the PCM samples encapsulated by an MLO_SampleBuffer object.

Typedef Documentation

typedef struct MLO_SampleBuffer MLO_SampleBuffer

MLO_SampleBuffer object.

An MLO_SampleBuffer object represents a buffer of PCM audio samples.


Enumeration Type Documentation

enum MLO_SampleType

Sample type indicating the way PCM sample values are encoded and layed out in memory.

Enumerator:
MLO_SAMPLE_TYPE_INTERLACED_SIGNED  Sample values are encoded as signed integers and the value for multiple audio channels are interleaved in memory.

For example, samples for stereo audio (two channels) are layed out in memory as: LRLRLRLRL... where L represents the value of a sample from the left channel, and R the value of a sample from the right channel.


Function Documentation

MLO_Result MLO_SampleBuffer_Create ( MLO_Size  size,
MLO_SampleBuffer **  buffer 
)

Create a new instance of an MLO_SampleBuffer object.

NOTE: this method is not intended to be called by clients of the MLO_Decoder API, since this API never takes MLO_SampleBuffer objects as input (always as output).

Parameters:
size Size in bytes of the buffer that this object should encapsulate.
buffer Pointer to a pointer where a pointer to an MLO_SampleBuffer object will be returned.
Returns:
MLO_SUCCESS if the object could be created, or an error code if it could not.

MLO_Result MLO_SampleBuffer_Destroy ( MLO_SampleBuffer self  ) 

Destroy an MLO_SampleBuffer object and free the resources associated with it.

Parameters:
self Pointer to the MLO_SampleBuffer object to destroy.
Returns:
MLO_SUCCESS if the call succeeded, or an error code if it failed.

const MLO_SampleFormat* MLO_SampleBuffer_GetFormat ( const MLO_SampleBuffer self  ) 

Return the format of the PCM samples encapsulated by an MLO_SampleBuffer object.

Parameters:
self Pointer to the MLO_SampleBuffer object of which the format should be retuned.
Returns:
Pointer to an MLO_SampleFormat struct containing the details of the format of the PCM samples encapsulated by this MLO_SampleBuffer object.

MLO_Cardinal MLO_SampleBuffer_GetSampleCount ( const MLO_SampleBuffer self  ) 

Return the number of audio samples encapsulated in a MLO_SampleBuffer object.

Parameters:
self Pointer to the MLO_SampleBuffer object of which the sample count should be retuned.
Returns:
The number of audio samples encapsulated by the MLO_SampleBuffer object.

const void* MLO_SampleBuffer_GetSamples ( const MLO_SampleBuffer self  ) 

Return a (const) pointer to the memory buffer containing the PCM audio samples encapsulated by an MLO_SampleBuffer object.

The returned pointer is maked 'const' to indicate that the caller may read but not write to the memory buffer.

Parameters:
self Pointer to the MLO_SampleBuffer object of which the samples should be retuned.
Returns:
Const pointer to a memory buffer. The encoding and layout of the PCM sample values in the buffer are determined by the MLO_SampleFormat format of this object.

MLO_Size MLO_SampleBuffer_GetSize ( const MLO_SampleBuffer self  ) 

Return the size of the buffer encapsulated in a MLO_SampleBuffer object.

Parameters:
self Pointer to the MLO_SampleBuffer object of which the buffer size should be retuned.
Returns:
The number of bytes in the buffer encapsulated by the MLO_SampleBuffer object.

void MLO_SampleBuffer_SetFormat ( MLO_SampleBuffer self,
const MLO_SampleFormat format 
)

Sets the format of the PCM samples encapsulated by an MLO_SampleBuffer object.

NOTE: this method only sets the format information, without doing any conversion on any existing data in the buffer. This method is typically only used by the internal implementation of the decoder, not by clients of the decoder API, since the decoder API never takes MLO_SampleBuffer objects as input.

Parameters:
self Pointer to the MLO_SampleBuffer object of which the format should be set.
format Pointer to an MLO_SampleFormat struct containing the details of the format of the PCM samples encapsulated by this MLO_SampleBuffer object.

MLO_Result MLO_SampleBuffer_SetSampleCount ( MLO_SampleBuffer self,
MLO_Cardinal  sample_count 
)

Set the number of audio samples encapsulated in a MLO_SampleBuffer object.

This method is typically only used by the internal implementation of the decoder, not by clients of the decoder API, since the decoder API never takes MLO_SampleBuffer objects as input.

Parameters:
self Pointer to the MLO_SampleBuffer object of which the sample count should be set.
Returns:
MLO_SUCCESS if the call succeeded, or an error code if it failed.

void* MLO_SampleBuffer_UseSamples ( MLO_SampleBuffer self  ) 

Return a pointer to the memory buffer containing the PCM audio samples encapsulated by an MLO_SampleBuffer object.

This method is similar to the MLO_SampleBuffer_GetSamples except that the returned pointer is not marked 'const', indicating that the caller may write to the memory buffer.

Parameters:
self Pointer to the MLO_SampleBuffer object of which the samples should be retuned.
Returns:
Const pointer to a memory buffer. The encoding and layout of the PCM sample values in the buffer are determined by the MLO_SampleFormat format of this object.