Adds sample data to a "push" stream.

DWORD BASS_StreamPutData(
    HSTREAM handle,
    void *buffer,
    DWORD length


handleThe stream handle.
bufferPointer to the sample data... NULL = allocate space in the queue buffer so that there is at least length bytes of free space.
lengthThe amount of data in bytes, optionally using the BASS_STREAMPROC_END flag to signify the end of the stream. 0 can be used to just check how much data is queued.

Return value

If successful, the amount of queued data is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_NOTAVAILThe stream is not using the push system.
BASS_ERROR_ILLPARAMlength is not valid, it must equate to a whole number of samples.
BASS_ERROR_ENDEDThe stream has ended.
BASS_ERROR_MEMThere is insufficient memory.


As much data as possible will be placed in the stream's playback buffer, and any remainder will be queued for when more space becomes available, ie. as the buffered data is played. With a decoding channel, there is no playback buffer, so all data is queued in that case. There is no limit to the amount of data that can be queued (besides available memory); the queue buffer will be automatically enlarged as required to hold the data, but it can also be enlarged in advance. The queue buffer is freed when the stream ends or is reset, eg. via BASS_ChannelPlay (with restart = TRUE) or BASS_ChannelSetPosition (with pos = 0).

DSP/FX are applied when the data reaches the playback buffer, or the BASS_ChannelGetData call in the case of a decoding channel.

Data should be provided at a rate sufficent to sustain playback. If the buffer gets exhausted, BASS will automatically stall playback of the stream, until more data is provided. BASS_ChannelGetData (BASS_DATA_AVAILABLE) can be used to check the buffer level, and BASS_ChannelIsActive can be used to check if playback has stalled. A BASS_SYNC_STALL sync can also be set via BASS_ChannelSetSync, to be triggered upon playback stalling or resuming.

See also

BASS_StreamCreate, STREAMPROC callback