BASS_ChannelIsActive intermittent on short samples in mixers

Started by smoogipoo,

smoogipoo

Hello!

We query BASS_ChannelIsActive() to update a boolean indicating whether we've finished playing or not. On short samples (in this case, ~30ms - it's part of our test suite), we're noticing the state flip-flopping between PLAYING and STOPPED, likely at the point of loop. It seems to only occur when a mixer is involved.

I've attached a C repro (containing both mixer and non-mixer variants) and the sample file (tone.wav).

Is this expected behaviour?

Ian @ un4seen

With looping decoding channels (BASS_STREAM_DECODE + BASS_SAMPLE_LOOP), there is indeed currently a window between the decoder ending and looping where BASS_ChannelIsActive will return 0. BASS_SYNC_END sync callbacks (and BASS_SYNC_POS syncs at the end position) occur in that window, and I guess it's possible that some users could be relying on BASS_ChannelIsActive returning 0 within those callbacks, so I'm not sure it's totally safe to close that window now. Is it causing problems for you?

Looping playback channels (without BASS_STREAM_DECODE) generally won't have that window because there's still data in the playback buffer, and BASS_ChannelIsActive won't return 0 until that's been played.

smoogipoo

We've worked around it, but I thought I'd bring it up anyway since it was unexpected for us (only failed in tests).

Ian @ un4seen

After thinking about it a bit more, I'm leaning towards closing the window mentioned above and having BASS_ChannelIsActive only return 0 after looping (including custom sync-based looping) has been considered, as that's when it's certain there's no more data coming. Here's an update (for macOS as that appears to be what you're using) with that change:

   www.un4seen.com/stuff/bass-osx.zip

Let me know if you (or anyone else) see any problems with it. Also let me know if you need it for different platform(s).