# Issue with callback DEVICELISTCHANGED

**URL:** <https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610>\
**Category:** FMOD Engine\
**Tags:** windows\
**Created:** [August 26, 2021, 2:09pm UTC](https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610 "2021-08-26T14:09:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndreaC](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@AndreaC](https://qa.fmod.com/u/AndreaC)\
**Post date:** [August 26, 2021, 2:09pm UTC](https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610/1 "2021-08-26T14:09:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [September 1, 2021, 12:26am UTC](https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610/2 "2021-09-01T00:26:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AndreaC](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@AndreaC](https://qa.fmod.com/u/AndreaC)\
**Post date:** [September 20, 2021, 2:43pm UTC](https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610/3 "2021-09-20T14:43:41Z")

</div>

Hi,

We are using FMOD version 2.01.06

```auto
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.

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

```

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [September 23, 2021, 4:40am UTC](https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610/4 "2021-09-23T04:40:34Z")

</div>

> [@AndreaC](#):
>
> ```auto
> 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.

---

<div class="post-metadata">

**Author:** ![AndreaC](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@AndreaC](https://qa.fmod.com/u/AndreaC)\
**Post date:** [September 23, 2021, 2:52pm UTC](https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610/5 "2021-09-23T14:52:15Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [September 27, 2021, 5:01am UTC](https://qa.fmod.com/t/issue-with-callback-devicelistchanged/17610/6 "2021-09-27T05:01:58Z")

</div>

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:

```cpp
#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.
