BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_ChannelUpdate Method BASS.NET API for the Un4seen BASS Audio Library
Updates the playback buffer of a stream or MOD music.

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

[DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)]
public static bool BASS_ChannelUpdate(
	int handle,
	int length
)

Parameters

handle
Type: SystemInt32
The channel handle... a HMUSIC or HSTREAM.
length
Type: SystemInt32
The amount to render, in milliseconds... 0 = default (2 x BASS_CONFIG_UPDATEPERIOD). This is capped at the space available in the buffer.

Return Value

Type: Boolean
If successful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

When starting playback of a stream or MOD music, after creating it or changing its position, there will be a slight delay while the initial data is decoded for playback. Usually the delay is not noticeable or important, but if you need playback to start instantly when you call BASS_ChannelPlay(Int32, Boolean), then use this function first. The length parameter should be at least equal to the BASS_CONFIG_UPDATEPERIOD.

It may not always be possible to render the requested amount of data, in which case this function will still succeed. BASS_ChannelGetData(Int32, IntPtr, Int32) (BASS_DATA_AVAILABLE) can be used to check how much data a channel has buffered for playback.

When automatic updating is disabled (BASS_CONFIG_UPDATEPERIOD = 0 or BASS_CONFIG_UPDATETHREADS = 0), this function could be used instead of BASS_Update(Int32) to implement different update periods for different channels, instead of a single update period for all. Unlike BASS_Update(Int32), this function can also be used while automatic updating is enabled.

The CPU usage of this function is not included in the BASS_GetCPU reading.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not a valid channel.
BASS_ERROR_NOTAVAILDecoding channels do not have playback buffers.
BASS_ERROR_ENDEDThe channel has ended.
BASS_ERROR_UNKNOWNSome other mystery problem!

Examples

Pre-buffer to enable instant playback:
VB
Dim stream As Integer = Bass.BASS_StreamCreateFile("afile.mp3", 0, 0, BASSFlag.BASS_STREAM_PRESCAN)
' pre-buffer
Bass.BASS_ChannelUpdate(stream, 0)
' start playback
Bass.BASS_ChannelPlay(stream, False)
int stream = Bass.BASS_StreamCreateFile("afile.mp3", 0, 0, BASSFlag.BASS_STREAM_PRESCAN);
// pre-buffer
Bass.BASS_ChannelUpdate(stream, 0);
// start playback
Bass.BASS_ChannelPlay(stream, false);
See Also

Reference