bluez5: deprioritize audio-gateway if remote is HFP HF + A2DP sink

If remote supports both HFP HF and AG, both may get connected, which
occurs with Pipewire<->Pipewire connection.  In this case, Pipewire on
both sides may pick the audio-gateway profile.

To avoid both sides being audio-gateway, if remote is both A2DP sink and
HF, use lower priority for the audio-gateway profile.  Generally, BlueZ
won't connect both A2DP Source and Sink between same devices at the same
time, so we use that to determine which side should be the receiver.
This commit is contained in:
Pauli Virtanen 2023-09-24 15:21:45 +03:00
parent 5f7afe588c
commit a9cc3f2813

View file

@ -1608,7 +1608,17 @@ static struct spa_pod *build_profile(struct impl *this, struct spa_pod_builder *
name = "audio-gateway"; name = "audio-gateway";
desc = _("Audio Gateway (A2DP Source & HSP/HFP AG)"); desc = _("Audio Gateway (A2DP Source & HSP/HFP AG)");
} }
priority = 256;
/*
* If the remote is A2DP sink and HF, we likely should prioritize being
* A2DP sender, not gateway. This can occur in PW<->PW if RFCOMM gets
* connected both as AG and HF.
*/
if ((device->connected_profiles & SPA_BT_PROFILE_A2DP_SINK) &&
(device->connected_profiles & SPA_BT_PROFILE_HEADSET_HEAD_UNIT))
priority = 15;
else
priority = 256;
break; break;
} }
case DEVICE_PROFILE_A2DP: case DEVICE_PROFILE_A2DP: