BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_StreamPutData Method (Int32, Byte, Int32, Int32)BASS.NET API for the Un4seen BASS Audio Library
Adds sample data to a "push" stream.

Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version:

public static int BASS_StreamPutData(
	int handle,
	byte[] buffer,
	int startIdx,
	int length


Type: SystemInt32
The stream handle (as created with BASS_StreamCreatePush(Int32, Int32, BASSFlag, IntPtr)).
Type: SystemByte
The array of byte sample data to provide.
Type: SystemInt32
The start index within the buffer to provide the data from.
Type: SystemInt32
The amount of data in bytes (starting at startIdx), 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

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

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(Int32, Boolean) (with restart = TRUE) or BASS_ChannelSetPosition(Int32, Int64, BASSMode) (with pos = 0).

DSP/FX are applied when the data reaches the playback buffer, or the BASS_ChannelGetData(Int32, IntPtr, Int32) 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(Int32, IntPtr, Int32) (BASS_DATA_AVAILABLE) can be used to check the buffer level, and BASS_ChannelIsActive(Int32) can be used to check if playback has stalled. A BASS_SYNC_STALL sync can also be set via BASS_ChannelSetSync(Int32, BASSSync, Int64, SYNCPROC, IntPtr), to be triggered upon playback stalling or resuming.

ERROR CODEDescription
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.

See Also