SHA256
1
0
forked from pool/pulseaudio
pulseaudio/0007-bluetooth-prefer-headset-HFP-HF-connection-with-nati.patch

57 lines
2.3 KiB
Diff
Raw Normal View History

From 815dd2d6278f17591fa04966b0e4c5a8b102cf0b Mon Sep 17 00:00:00 2001
From: "Igor V. Kovalenko" <igor.v.kovalenko@gmail.com>
Date: Fri, 29 Jan 2021 09:28:36 +0300
Subject: [PATCH 07/11] bluetooth: prefer headset HFP HF connection with native
backend
When HFP HF support is enabled in native backend, peer HFP HF profile connection
is preferred over same peer HSP HS profile connection if peer supports both
profiles.
Enforce the preference by rejecting HSP HS profile connections from such peer.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
---
src/modules/bluetooth/backend-native.c | 10 ++++++++++
src/modules/bluetooth/module-bluez5-device.c | 10 ----------
2 files changed, 10 insertions(+), 10 deletions(-)
--- a/src/modules/bluetooth/backend-native.c
+++ b/src/modules/bluetooth/backend-native.c
@@ -645,6 +645,16 @@ static DBusMessage *profile_new_connecti
goto fail;
}
+ if (pa_bluetooth_discovery_get_enable_native_hfp_hf(b->discovery)) {
+ if (p == PA_BLUETOOTH_PROFILE_HSP_HS && pa_hashmap_get(d->uuids, PA_BLUETOOTH_UUID_HFP_HF)) {
+ /* If peer connecting to HSP Audio Gateway supports HFP HF profile
+ * reject this connection to force it to connect to HSP Audio Gateway instead.
+ */
+ pa_log_info("HFP HF enabled in native backend and is supported by peer, rejecting HSP HS peer connection");
+ goto fail;
+ }
+ }
+
pa_assert_se(dbus_message_iter_next(&arg_i));
pa_assert(dbus_message_iter_get_arg_type(&arg_i) == DBUS_TYPE_UNIX_FD);
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -2072,16 +2072,6 @@ static int add_card(struct userdata *u)
PA_HASHMAP_FOREACH(uuid, d->uuids, state) {
pa_bluetooth_profile_t profile;
- if (!enable_native_hfp_hf && pa_streq(uuid, PA_BLUETOOTH_UUID_HFP_HF)) {
- pa_log_info("device supports HFP but disabling profile as requested");
- continue;
- }
-
- if (has_both && pa_streq(uuid, PA_BLUETOOTH_UUID_HSP_HS)) {
- pa_log_info("device support HSP and HFP, selecting HFP only");
- continue;
- }
-
if (uuid_to_profile(uuid, &profile) < 0)
continue;