Commit 1a3ffd4c authored by Igor Kovalenko's avatar Igor Kovalenko Committed by PulseAudio Marge Bot
Browse files

bluetooth: Fix device->adapter dependency while releasing discovery

Change d7f95170 added a dependency on device
adapter pointer being valid while checking if bluetooth profile is supported by

When adapter object is released, each device holding pointer to adapter being
released is notified to reset that to NULL. Since adapter objects are released
first when discovery object is unreferenced, each device will have adapter
pointer reset before the time device objects are released.

Fix observed crash by examining device adapter pointer. If it is NULL report
that device does not support any bluetooth profile instead of looking at UUIDs
supported by adapter.

Part-of: <pulseaudio/pulseaudio!646>
parent 0c567239
Pipeline #448313 passed with stages
in 2 minutes and 58 seconds
......@@ -257,6 +257,17 @@ static const char *transport_state_to_string(pa_bluetooth_transport_state_t stat
bool pa_bluetooth_device_supports_profile(const pa_bluetooth_device *device, pa_bluetooth_profile_t profile) {
bool show_hfp, show_hsp, r;
/* While discovery is being released adapters will be removed from devices,
* and there are no profiles to support without adapter.
if (!device->adapter) {
pa_log_debug("Device %s (%s) has no adapter to support profile %s",
device->alias, device->address, pa_bluetooth_profile_to_string(profile));
return false;
if (device->enable_hfp_hf) {
show_hfp = pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HFP_HF);
show_hsp = !show_hfp;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment