[Win10] FMOD 2.0 not automatically switching output / detecting device changes in certain cases, with description

Hello, I have a Windows 10 laptop (ROG Ryzen 9) and I’ve encountered a case where FMOD 2.0 (October 2021 code) seems not to detect devices changing at all. FMOD both fails to automatically switch output to the new device, and doesn’t trigger either a FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED callback (also no FMOD_SYSTEM_CALLBACK_DEVICELOST callback).

Diagnosis:

  • If I run the program without headphones plugged into the jack (not USB), then plug them in, FMOD correctly detects the device change. It switches output to the headphones and generates the callback.
    From there I can unplug/replug them and it works each time, FMOD switches output, etc.
  • If I run the program with headphones plugged in, then unplug them, FMOD will not detect the device change nor switch output to the speaker. It will also not detect plugging them in again or any further changes, so sound is completely lost until the program is closed and re-run.

All other programs (Chrome, Media Player, Winamp, etc.) correctly detect the device change and switch between speakers and headphones. This may be an internal FMOD situation?

Thank you,
Mike

Can you please share a code snippet of your device change callback and where you are setting it? It does sound like a bug if it isn’t behaving the same for starting plugged in and starting unplugged.
Can you please provide a full FMOD version, i.e 2.01.11, so I can reproduce it?

The callback is very simple, and I only added it to help diagnose the behavior of FMOD not auto-switching:

FMOD_RESULT F_CALLBACK DeviceListChangedCallback(FMOD_SYSTEM * /*system*/, FMOD_SYSTEM_CALLBACK_TYPE /*type*/, void *, void *, void *userData)
{
	OutputDebugStringA("FMOD: Device list changed.\n");
	return FMOD_OK;
}
	FMOD_RESULT result = pFMOD_CORE_SYSTEM->setCallback(&DeviceListChangedCallback, FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED
		| FMOD_SYSTEM_CALLBACK_DEVICELOST
		| FMOD_SYSTEM_CALLBACK_DEVICEREINITIALIZE);
	if(result != FMOD_OK)
	{
		OutputDebugStringA("FMOD error setting device-list-changed callback: (%d) %s\n", result, FMOD_ErrorString(result));
		exit(-1);
	}

Revision.txt has

9/9/21 2.02.03 - Studio API minor release (build 120077)

And this is the laptop.

If you’d like, I can run a debug version of the lib that you build with any extra logging info, to help diagnose the problem.

Mike

Thanks for the extra info- all looks fine there. One thing to check is that you aren’t setting the callback before FMOD::System_Create otherwise it won’t be registered.
Other than that, setting an FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED or FMOD_SYSTEM_CALLBACK_ALL callback means you need to handle device changes yourself. Do you have another callback somewhere set to the default of FMOD_SYSTEM_CALLBACK_ALL?

If not, to work backwards from the problem I suggest you try changing your callback type to FMOD_SYSTEM_CALLBACK_ALL and see if that ever gets called. If not, can you please try running the user_created_sound or programmer_sound example and see if the callbacks in either of those gets fired?