Detecting Playback Device Change in Windows

I’m trying to ensure my application changes driver when the user changes the default playback device in Windows. How can I detect when this occurs?

It appears the driver order does not change when the default is changed in Windows, but it does update when a device is connected or disconnected. This means the statement “driver 0 is always the system default” is not true.

The most efficient thing to do once a frame is to check the number of devices available, FMOD can do this cheaply with the waveOutGetNumDevs (sp) function - enumerating the whole sound card list repeatedly is very expensive, and not worth it for the return gained.

It is the most common use case to determine if a device list has changed, due to a new device being inserted, or a device being ejected. FMOD supports this.
Changing the default device is an action the user knowingly takes in the control panel (its not the same as yanking out USB headphones), and therefore they have the power to change the game sound device themselves in game as well. This can be done with getDriverInfo/setDriver and an in app UI, alternatively they can restart the application.

We’re just going off the common use case here, although it is technically possible, a very very low percentage of apps support default device change detection (i’ve never seen one), so we opt for the most used case, with the best performance. I’d ask if this feature was strictly necessary for your application?

Strictly necessary? Maybe not. But I make software that is pleasant to use and that often means going a little beyond the bare minimum.

While respecting the default device in real time may be the minority, A good number of the applications I use day to day support this. Chrome, Firefox, and Overwatch for example. Overwatch’s implementation is ideal, imo. When selecting the audio device in the settings I can choose Device A, Device B, or Default Device. If I choose Device A obviously the game will only play through that device as long as it’s connected. If I choose Default Device it will play through whatever device is currently set as default and will update in real time.

I feel this is important because there are reasonable circumstances in which players want to change between devices that are already connected to the system. I, for example, have a wireless headset with a base station plugged in over USB. This device is always connected from the OS’s point of view. If I join a group that wants to use voice chat or my roommate starts a movie I turn on my headset and press a keybinding to swap my default audio device in Windows. I’d really rather not have to restart my game because my girlfriend is going to bed.

My boss and I believe this is important enough to support through platform specific code if it’s not something FMOD is capable of doing out of the box, but it would be very much appreciated if it’s something you would consider supporting. I’d be ok if it’s a little more manual on our end. A callback we can handle and change the driver manually, for example.

I like to push the bar a little higher when I can because it puts the competition one small step behind.

Right now you can override fmod’s behaviour with FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED

You will get callbacks every time something happens (except default device changed) , we’ll look at creating a separate wasapi notifier for a future version to handle default device changed.