Issue with callback DEVICELISTCHANGED

FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED callback is not called when an external audio interface driver is selected and the interface is unplugged.

These are the steps I’ve followed:

  1. Play audio through internal audio interface driver
  2. Plug an external audio interface
  3. DEVICELISTCHANGED callback is called and I can see the list of updated drivers (both internal and external)
  4. The audio still plays through the selected driver
  5. Select a driver of the external interface (setDriver)
  6. Audio is now played through the external interface
  7. Unplug the external interface, DEVICELISTCHANGED callback is not called
  8. If the internal interface driver is selected on external interface unplugging the callback is called

Is there a workaround for this?

I have not been able to reproduce this issue with the latest FMOD version, can you please share the code for your device change callback and let me know your FMOD version so I can try debugging?

Hi,

We are using FMOD version 2.01.06

static FMOD_RESULT F_CALLBACK SystemCallback(FMOD_SYSTEM* system, FMOD_SYSTEM_CALLBACK_TYPE type, void*, void*, void* userData)
{
	FMOD_manager* device_manager = (FMOD_manager*)userData;
	if (device_manager != nullptr)
	{
		device_manager->FMOD_device_callback.dispatch_callback();
	}

	return FMOD_OK;
}

We use another callback to handle the device list changed event.
The FMOD System callback is set in the custom FMOD_manager class constructor.

FMOD_manager::FMOD_manager() {
.
.
.
FMOD_System_SetCallback(system, &SystemCallback, FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED || FMOD_SYSTEM_CALLBACK_DEVICELOST)
.
.
.
}

You should be using bitwise or “|” not the or operator “||” to combine flags together. Removing the second vertical bar should resolve your issue, i.e
FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED | FMOD_SYSTEM_CALLBACK_DEVICELOST
If that’s still not working I might need more details on the FMOD_manager class, in which case you can upload it to your profile to share with us privately.

Hi,

Thanks for the reply. I’ve updated the flag but that is not solving the issue.

Is audio otherwise working properly and are you getting any errors anywhere? Using ERRCHECK can be a handy way to quickly track down any failing API calls.
Based on the code you’ve provided here, you should be able to get the device change callback firing with the following:

#include "fmod.hpp"
#include "common.h"
#include <iostream>

class FMOD_manager
{
public:
	FMOD_manager::FMOD_manager()
	{
		Common_Init(&extradriverdata);

		ERRCHECK(FMOD_System_Create(&system));
		ERRCHECK(FMOD_System_Init(system, 100, FMOD_INIT_NORMAL, extradriverdata));
		ERRCHECK(FMOD_System_SetCallback(system, &SystemCallback, FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED | FMOD_SYSTEM_CALLBACK_DEVICELOST));
	}

    FMOD_manager::~FMOD_manager()
    {
        FMOD_System_Release(system);
        FMOD_System_Close(system);

        Common_Close();
    }

    void FMOD_manager::Update()
    {
        FMOD_System_Update(system);
    }
 
    static FMOD_RESULT F_CALLBACK SystemCallback(FMOD_SYSTEM* system, FMOD_SYSTEM_CALLBACK_TYPE type, void*, void*, void* userData)
	{
		std::cout << "Device changed detected!" << std::endl;
		return FMOD_OK;
	}

    FMOD_SYSTEM* system;
private:
	void* extradriverdata = 0;
};

int FMOD_Main()
{
    FMOD_manager* m = new FMOD_manager();

    do
    {
        m->Update();     
        Common_Sleep(50);
    } while (!Common_BtnPress(BTN_QUIT));

    delete m;

    return 0;
}

If you have any code you can share I can help you debug it.