Changes the device that a stream, MOD music or sample is using.

BOOL BASS_ChannelSetDevice(
    DWORD handle,
    DWORD device


handleThe channel or sample handle... a HMUSIC, HSTREAM or HSAMPLE.
deviceThe device to use... 0 = no sound, 1 = first real output device, BASS_NODEVICE = no device.

Return value

If successful, TRUE is returned, else FALSE is returned and the channel remains on its current device. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_HANDLEhandle is not a valid channel.
BASS_ERROR_DEVICEdevice is invalid.
BASS_ERROR_INITThe requested device has not been initialized.
BASS_ERROR_ALREADYThe channel is already using the requested device.
BASS_ERROR_NOTAVAILOnly decoding channels are allowed to use the BASS_NODEVICE option. Final output mix streams (using STREAMPROC_DEVICE) cannot be moved to another device.
BASS_ERROR_FORMATThe sample format is not supported by the device/drivers. If the channel is more than stereo or the BASS_SAMPLE_FLOAT flag is used, it could be that they are not supported.
BASS_ERROR_MEMThere is insufficient memory.
BASS_ERROR_UNKNOWNSome other mystery problem!


All of the channel's current settings are carried over to the new device, but if the channel is using the "with FX flag" DX8 effect implementation, the internal state (eg. buffers) of the DX8 effects will be reset. When using the "without FX flag" DX8 effect implementation, the state of the DX8 effects is preserved.

When changing a sample's device, all the sample's existing channels (HCHANNELs) are freed. It is not possible to change the device of an individual sample channel.

The BASS_NODEVICE option can be used to disassociate a decoding channel from a device, so that it does not get freed when BASS_Free is called.

See also

BASS_ChannelGetDevice, BASS_Init