mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-20 08:00:05 +01:00
Merge branch 'fix-audio-connection' into 'master'
spa: bluez: backend-native: Fix audio connection policy for HSP/HFP See merge request pipewire/pipewire!2638
This commit is contained in:
commit
c2054c69e0
1 changed files with 43 additions and 2 deletions
|
|
@ -2942,7 +2942,11 @@ static void sco_listen_event(struct spa_source *source)
|
||||||
|
|
||||||
/* Find transport for local and remote address */
|
/* Find transport for local and remote address */
|
||||||
spa_list_for_each(rfcomm, &backend->rfcomm_list, link) {
|
spa_list_for_each(rfcomm, &backend->rfcomm_list, link) {
|
||||||
if ((rfcomm->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY) &&
|
/* Audio connection is allowed from both side with legacy peer, i.e. HSP or codec negotion not supported
|
||||||
|
* (except if PTS workaround has been enabled in which case audio coonection is allowed as for HSP),
|
||||||
|
* or only from the HFP Audio Gateway. */
|
||||||
|
if ((((!rfcomm->codec_negotiation_supported || backend->pts) && (rfcomm->profile & SPA_BT_PROFILE_HEADSET_AUDIO)) ||
|
||||||
|
(rfcomm->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY)) &&
|
||||||
rfcomm->transport &&
|
rfcomm->transport &&
|
||||||
spa_streq(rfcomm->device->address, remote_address) &&
|
spa_streq(rfcomm->device->address, remote_address) &&
|
||||||
spa_streq(rfcomm->device->adapter->address, local_address)) {
|
spa_streq(rfcomm->device->adapter->address, local_address)) {
|
||||||
|
|
@ -2956,7 +2960,7 @@ static void sco_listen_event(struct spa_source *source)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_assert(t->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY);
|
spa_assert(t->profile & SPA_BT_PROFILE_HEADSET_AUDIO);
|
||||||
|
|
||||||
if (rfcomm->telephony_ag && rfcomm->telephony_ag->transport.rejectSCO) {
|
if (rfcomm->telephony_ag && rfcomm->telephony_ag->transport.rejectSCO) {
|
||||||
spa_log_info(backend->log, "rejecting SCO, AudioGatewayTransport1.RejectSCO=true");
|
spa_log_info(backend->log, "rejecting SCO, AudioGatewayTransport1.RejectSCO=true");
|
||||||
|
|
@ -3397,6 +3401,43 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag
|
||||||
}
|
}
|
||||||
spa_bt_device_add_profile(d, profile);
|
spa_bt_device_add_profile(d, profile);
|
||||||
|
|
||||||
|
/* Prevent to connect HSP/HFP in both directions, i.e. HS->AG and AG->HS.
|
||||||
|
* This may only occur when connecting to a device which provides both
|
||||||
|
* HS and AG which should not be the case with headsets and phones. */
|
||||||
|
spa_list_for_each(rfcomm, &backend->rfcomm_list, link) {
|
||||||
|
if (spa_streq(rfcomm->device->address, d->address) &&
|
||||||
|
spa_streq(rfcomm->device->adapter->address, d->adapter->address)) {
|
||||||
|
bool connected = false;
|
||||||
|
|
||||||
|
switch (profile) {
|
||||||
|
case SPA_BT_PROFILE_HFP_HF:
|
||||||
|
if (rfcomm->profile == SPA_BT_PROFILE_HFP_AG)
|
||||||
|
connected = true;
|
||||||
|
break;
|
||||||
|
case SPA_BT_PROFILE_HFP_AG:
|
||||||
|
if (rfcomm->profile == SPA_BT_PROFILE_HFP_HF)
|
||||||
|
connected = true;
|
||||||
|
break;
|
||||||
|
case SPA_BT_PROFILE_HSP_HS:
|
||||||
|
if (rfcomm->profile == SPA_BT_PROFILE_HSP_AG)
|
||||||
|
connected = true;
|
||||||
|
break;
|
||||||
|
case SPA_BT_PROFILE_HSP_AG:
|
||||||
|
if (rfcomm->profile == SPA_BT_PROFILE_HSP_HS)
|
||||||
|
connected = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
spa_log_warn(backend->log, "Unsupported profile: %s", handler);
|
||||||
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connected) {
|
||||||
|
spa_log_debug(backend->log, "Already connected in the opposite direction");
|
||||||
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dbus_message_iter_next(&it);
|
dbus_message_iter_next(&it);
|
||||||
dbus_message_iter_get_basic(&it, &fd);
|
dbus_message_iter_get_basic(&it, &fd);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue