Author Topic: BASS_WASAPI_GetLevel handing loss of device  (Read 880 times)

It would seem that BASS_WASAPI_GetLevel() gets stuck when you disable (and then enable) the current device from windows sound device settings.
This is also what happens when you unplug and plug back in a USB headset, which is the main problem for a background application that is not meant to be restarted, ever.

BASS_WASAPI_GetDeviceLevel seems to unaffected by this and works as intended.

My program does handle device switching properly, so if I would just SWITCH the default device without disabling anything, it works properly.

Also it seems that BASS_WASAPI_GetDeviceLevel updates slower than BASS_WASAPI_GetLevel or it has less precision or something.

Using the latest bass.dll ( ) and basswasapi.dll (

Ian @ un4seen

  • Administrator
  • Posts: 21791
Re: BASS_WASAPI_GetLevel handing loss of device
« Reply #1 on: 1 Oct '18 - 15:42 »
I don't seem to be able to reproduce that here. The CONTEST example (included in the BASSWASAPI package) uses BASS_WASAPI_GetLevel, so I tried to reproduce the problem with that by removing the "Sleep" call from its loop. Can you reproduce the problem if you try that there? Also, does it happen when using shared or exclusive mode, or both? And playback or recording devices, or both?

Regarding BASS_WASAPI_GetLevel vs BASS_WASAPI_GetDeviceLevel, BASS_WASAPI_GetLevel measures the level of the data buffered by BASSWASAPI (enabled by BASS_WASAPI_BUFFER), while BASS_WASAPI_GetDeviceLevel gets the level from the device/driver. So the precision of the latter will depend on the driver.

Re: BASS_WASAPI_GetLevel handing loss of device
« Reply #2 on: 7 Oct '18 - 02:29 »
Sorry for delayed reply, I sort of expected noone to give a crap.

Anyway, the problem does persist with contest. It happens with both shared and exclusive modes, its probably both playback and recording devices.
In my use case I use BASS_WASAPI to capture FFT data and loudness of the audio of windows output device, based on the livespec example program, I do feed BASS the proper "input version of an output device" for this.

Here's a video demonstrating the problem in contest:
(The sound in exclusive mode does work, but isn't picked up by the recording software I used.)

The same thing happens when I unplug the USB headset and plug it back in, or if just disable the Speakers and then enable them when they are the only playback device.
« Last Edit: 7 Oct '18 - 02:58 by WhyYouForceMeToRegister »

Ian @ un4seen

  • Administrator
  • Posts: 21791
Re: BASS_WASAPI_GetLevel handing loss of device
« Reply #3 on: 8 Oct '18 - 14:44 »
The issue there is that BASSWASAPI's device instance will have been invalidated when the device was disabled. To resume, the device will need to be reinitialized, ie. BASS_WASAPI_Free and BASS_WASAPI_Init called again. The CONTEST example doesn't currently implement this, but you can detect when the device has been invalidated by using BASS_WASAPI_SetNotify and receiving a BASS_WASAPI_NOTIFY_FAIL notification. When you receive that notification, you can call BASS_WASAPI_Free (but not within the callback function) and then periodically call BASS_WASAPI_GetDeviceInfo to check if the device is available again (BASS_DEVICE_ENABLED flag set) before calling BASS_WASAPI_Init on it again. Or you could call BASS_WASAPI_Init on a different device. Please see the documentation for details on the mentioned functions.

Re: BASS_WASAPI_GetLevel handing loss of device
« Reply #4 on: 9 Oct '18 - 17:49 »
Thank you for the help. I see what the problem on my end was now.

I was trying to call BASS_WASAPI_Free from the callback previously which is why it didn't work. Just tried outside the callback and works flawlessly now!

You should really put this (the fact that you shouldn't call BASS_WASAPI_Free in a SetNotify callback) into the documentation for BASS_WASAPI_Free ( ), because it is not mentioned there and I missed the note on WASAPINOTIFYPROC documentation.