Author Topic: BASS_CONFIG_DEV_DEFAULT issue when default device disappears  (Read 231 times)

nicorac

  • Posts: 40
Starting from version 2.3.0, I've added to VirtualMIDISynth a feature to "follow" the default Windows device thanks to BASS_CONFIG_DEV_DEFAULT.
It works perfectly when user switches default device between active and existing devices.

When the last (or the only one enabled) device "disappears" (i.e. headphones unplugged while playing), BASS seems to switch to no-sound device... and that's ok.
But when that device gets back (and it's still the default one), BASS does not detect the change and won't play anymore.
Also BASS_ChannelGetLevel() calls (used by VirtualMIDISynth mixer to show MIDI output level) get stuck to latest value.
The only way to get it back working is to restart process.

I suppose this bug is not specific to VirtualMIDISynth, any BASS executable using BASS_CONFIG_DEV_DEFAULT should be enough.

These are the steps to reproduce it:
  • Win10 laptop with 2 devices: internal speakers (disabled) and headphones (enabled and default)
  • Start playing, sound is played by headphones
  • Unplug headphones, no more sound (internal speakers are disabled) and no errors from BASS
  • Plug headphones back in, Windows set them as default device but still no sound from BASS

Thanks
Claudio

Ian @ un4seen

  • Administrator
  • Posts: 20772
BASS won't be switching to the "no sound" device in that case, but the output will stop. If you're using WASAPI output with BASS 2.4.13 then it should be possible to get it going again by calling BASS_Start after the device becomes re-available. Otherwise, you will probably need to reinitialize the device by calling BASS_Free and BASS_Init again.

nicorac

  • Posts: 40
I'm actually not using WASAPI but probably will in the near future...
BASS won't be switching to the "no sound" device in that case, but the output will stop.
Is there a way to be notified of this event?
If yes then I could show an info message to the users asking them to restart the program...

Ian @ un4seen

  • Administrator
  • Posts: 20772
Is there a way to be notified of this event?

Unfortunately, not. One way you could detect the output stopping is if the playback position (from BASS_ChannelGetPosition) stops moving.

When using WASAPI output with BASS 2.4.13, BASS_ChannelPlay calls will fail with BASS_ERROR_START after the output has stopped, so you could use that as a signal to try calling BASS_Start. But note that BASS_Start will currently report success in its return value even if the output can't actually be restarted (it'll only report a failure if BASS_Init hasn't been called).

I'll see if this stuff can be improved for the next BASS release.

nicorac

  • Posts: 40
One way you could detect the output stopping is if the playback position (from BASS_ChannelGetPosition) stops moving.
Can't use it because VirtualMIDISynth does not play a file but a live MIDI stream received through a virtual MIDI-In.

I'll see if this stuff can be improved for the next BASS release.
Thanks for taking it into account.
May I suggest to add something similar to channel syncs? Something like BASS_SYNC_DEVICE_STOP...
I know that this is a device-level event and syncs are channel level "events", but maybe all channels linked to a device could receive this event and propagate it outside through syncs.

Obviously you've a better knowledge of BASS internals than me; just my 2 cents ;)

Ian @ un4seen

  • Administrator
  • Posts: 20772
One way you could detect the output stopping is if the playback position (from BASS_ChannelGetPosition) stops moving.
Can't use it because VirtualMIDISynth does not play a file but a live MIDI stream received through a virtual MIDI-In.

BASS_ChannelGetPosition will still work then.

May I suggest to add something similar to channel syncs? Something like BASS_SYNC_DEVICE_STOP...
I know that this is a device-level event and syncs are channel level "events", but maybe all channels linked to a device could receive this event and propagate it outside through syncs.

Yes, that could be an option. I will look into it.

Falcosoft

  • Guest
I'm actually not using WASAPI but probably will in the near future...
You/We are actually using WASAPI output since you have already updated VMS to BASS 2.4.13. The new WASAPI output mode is the default mode of Bass 2.4.13 on Vista/7/8/10. You have to explicitly use the new BASS_DEVICE_DSOUND flag in Bass_Init() to use the old Directsound output mode (that VMS used before BASS 2.4.13).

nicorac

  • Posts: 40
Thanks to its very good backward compatibility, I often don't read BASS changelog with the needed care ;)

@Falcosoft: thanks for pointing it out.
« Last Edit: 14 Feb '18 - 22:54 by nicorac »