A user reported that the application crashes when they takes off their airpods while the device is selected as default device.
I tracked this down to cubeb_enumerate_devices.
In particular, we try to reconnect a new default device in the device_collection_changed_cb.
EDIT: the default device is connected and a stream is open before the airpods are taken off
So here's a snippet:
void MyClass::init()
{
if (int err = cubeb_init(&m_context, "MyContext", nullptr))
{
printf("Error in cubeb_init\n");
return;
}
if (int err = cubeb_register_device_collection_changed(m_context, CUBEB_DEVICE_TYPE_OUTPUT, device_collection_changed_cb, this))
{
printf("Error in cubeb_register_device_collection_changed\n");
return;
}
}
void MyClass::device_collection_changed_cb(cubeb* context, void* user_ptr)
{
if (context == nullptr) return;
cubeb_device_collection collection{};
printf("Begin enumeration\n"); // THIS WAS THE LAST LOG MESSAGE
int err = cubeb_enumerate_devices(context, CUBEB_DEVICE_TYPE_OUTPUT, &collection);
// THIS IS NEVER REACHED
if (err != CUBEB_OK)
{
printf("Error in cubeb_enumerate_devices\n");
return;
}
// Do other cool stuff
}
A user reported that the application crashes when they takes off their airpods while the device is selected as default device.
I tracked this down to cubeb_enumerate_devices.
In particular, we try to reconnect a new default device in the device_collection_changed_cb.
EDIT: the default device is connected and a stream is open before the airpods are taken off
So here's a snippet: