Author Topic: how to get channels list  (Read 469 times)

MB_SOFT

  • Posts: 496
how to get channels list
« on: 15 Feb '24 - 13:42 »
is it possibile to get current channels list?

for ex there is BASS_Mixer_StreamGetChannels that give me the list of channels added to a specific mixer but in my case i have to investigate a leak and i need a list of all the channel handles including those that have not been added to any mixer

could you please add a BASS_StreamGetChannels or BASS_GetChannels function?
« Last Edit: 15 Feb '24 - 13:57 by MB_SOFT »

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: how to get channels list
« Reply #1 on: 15 Feb '24 - 15:07 »
The only way to get a list of all BASS channel handles currently is to retain them yourself as you create them. The thing is some add-ons create channels internally (eg. for decoding), which shouldn't be manipulated outside of it and the safest way to prevent that is to keep them private.

If you happen to want to get the handle list to detect leaks, then the BASS_CONFIG_HANDLES option (which gives the total number of handles) can be useful for that purpose.

MB_SOFT

  • Posts: 496
Re: how to get channels list
« Reply #2 on: 15 Feb '24 - 15:19 »
my app is really big so it would not be pratical to retain every bass call that create a channel, but i remarked that on win32 the first channel handle is always -2147483648 and keep increasing in subsequent calls  so i can check if a channel exist testing BASS_ChannelGetDevice in a loop starting from -2147483648 to the latest created bass handle

tested and it works
« Last Edit: 15 Feb '24 - 15:59 by MB_SOFT »

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: how to get channels list
« Reply #3 on: 15 Feb '24 - 16:51 »
Yes, the handles do increment so you could do that, but you would then need to at least retain the latest handle to know where to stop checking - you can't just stop when BASS_ChannelGetDevice fails because there may be gaps in the sequence, eg. from freed channels but also from DSP/FX or sync handles in amongst them. You would also need to ignore the internal handles I mentioned, perhaps using BASS_ATTRIB_USER to mark yours.

I really do think it'd be better to just retain the created handles, eg. in an array/vector. It shouldn't need much extra code, basically an extra line after each channel creation. You could also use BASS_SYNC_FREE syncs to remove freed handles from the list, or just remove them when you check the list and find invalid/freed ones in it.

MB_SOFT

  • Posts: 496
Re: how to get channels list
« Reply #4 on: 15 Feb '24 - 17:06 »
for now i solved with this

Code: [Select]
dummych = BASS_StreamCreate(44100, 1, BASS_STREAM_DECODE, STREAMPROC_DUMMY, 0)
 Void BASS_StreamFree(dummych)
 For myhandle = _minInt To dummych
      If BASS_ChannelGetDevice(myhandle) => 0
        ' do what you need with the handle
      EndIf
 Next myhandle