Changes the reference count of a stream, MOD music or recording channel.
BOOL BASS_ChannelRef( DWORD handle, BOOL inc );
handle | The channel handle... a HMUSIC, HSTREAM or HRECORD. |
inc | Increment or decrement the reference count... TRUE = increment, FALSE = decrement. |
BASS_ERROR_HANDLE | handle is not a valid channel. |
BASS_ERROR_ALREADY | The channel already has a 0 reference count so cannot be decremented. |
BASS_ERROR_FREEING | The channel's reference count cannot be incremented because it is being freed. |
This can be useful when accessing the channel's memory (eg. tags) to ensure that it is not freed in the meantime by another thread. The reference count can be incremented and decremented by different threads.
if (BASS_ChannelRef(channel, true)) { // increment reference count const TAG_ID3 *tags = (const TAG_ID3*)BASS_ChannelGetTags(channel, BASS_TAG_ID3); // get the ID3 tags // process the tags here BASS_ChannelRef(channel, false); // decrement reference count }
Free a channel asynchronously.
if (BASS_ChannelRef(channel, true)) { // increment reference count BASS_ChannelFree(channel); // invalidate the channel BASS_ChannelRef(channel, false); // decrement reference count and free the channel }