C4 Engine
C4 Engine API Documentation

SoundStreamer::FillBuffer

Defined in:  C4Sound.h
Called when audio data is needed.
Prototype

virtual bool FillBuffer(uint32 bufferSize, Sample *buffer, int32 *count) = 0;

Parameters
bufferSize The number of bytes of audio data that is needed.
buffer A pointer to the buffer that is to receive the audio data.
count A pointer to an integer that receives the total number of frames written to the buffer.
Description
The Sound Manager calls the FillBuffer function when audio data is needed from a stream. The streamer should fill the buffer specified by the buffer parameter with as many audio samples as possible without exceeding the byte count specified by the bufferSize parameter. Each audio sample is 16 bits in size, and the data should be stored in little endian byte order.

The value of bufferSize will never be larger than the value of the streamSize parameter passed to the SoundStreamer::AllocateStreamMemory function. The actual number of audio frames written to the buffer should be written to the integer pointed to by the count parameter.

The return value should be true if there is more audio data available in the stream after filling the buffer, and it should be false if the end of the stream has been reached.
Special Considerations
The FillBuffer function can be called in the main thread or in a special streaming thread maintained by the Sound Manager. The implementation of this function should not make any assumptions about which thread it's running in, and it should take care to use proper multithreaded synchronization where necessary.
See Also

SoundStreamer::StartStream

SoundStreamer::StartStreamComponent

SoundStreamer::AllocateStreamMemory