SHA256
1
0
forked from pool/pulseaudio
pulseaudio/0006-bluetooth-fix-headset-auto-ofono-handover.patch
Takashi Iwai 236e29d4cf Accepting request 877714 from home:tiwai:branches:multimedia:libs
- Upstream fixes for supporting HFP in native backend (bsc#1167940):
  0001-bluetooth-use-consistent-profile-names.patch
  0002-bluetooth-separate-HSP-and-HFP.patch
  0003-bluetooth-add-correct-HFP-rfcomm-negotiation.patch
  0004-bluetooth-make-native-the-default-backend.patch
  0005-bluetooth-enable-module-bluez5-discover-argument-ena.patch
  0006-bluetooth-fix-headset-auto-ofono-handover.patch
  0007-bluetooth-prefer-headset-HFP-HF-connection-with-nati.patch
  0008-bluetooth-complete-bluetooth-profile-separation.patch
  0009-bluetooth-use-device-flag-to-prevent-assertion-failu.patch
  0010-bluetooth-rename-enable_hs_role-to-enable_shared_pro.patch
  0011-bluetooth-clean-up-rfcomm_write-usage.patch

OBS-URL: https://build.opensuse.org/request/show/877714
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/pulseaudio?expand=0&rev=234
2021-03-08 12:50:38 +00:00

132 lines
5.3 KiB
Diff

From 70171158eeda4e3ae44a6a2dd22b25cc6932dd04 Mon Sep 17 00:00:00 2001
From: "Igor V. Kovalenko" <igor.v.kovalenko@gmail.com>
Date: Thu, 28 Jan 2021 09:08:53 +0300
Subject: [PATCH 06/11] bluetooth: fix headset=auto ofono handover
Native backend implements HFP AG but not HFP HF yet, therefore headset=auto
functionality is still needed if HFP HF is required.
To make headset=auto work again, drop both HFP AG and HSP AG roles while
performing handover from native backend when oFono is detected running.
While at it, restore profile description to Headset Head Unit (HSP/HFP)
to note that HFP may be still provided via oFono backend.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
---
src/modules/bluetooth/backend-native.c | 31 +++++++++++++++++----------
src/modules/bluetooth/bluez5-util.c | 8 +++---
src/modules/bluetooth/module-bluez5-device.c | 2 -
3 files changed, 25 insertions(+), 16 deletions(-)
--- a/src/modules/bluetooth/backend-native.c
+++ b/src/modules/bluetooth/backend-native.c
@@ -41,6 +41,7 @@ struct pa_bluetooth_backend {
pa_dbus_connection *connection;
pa_bluetooth_discovery *discovery;
bool enable_hs_role;
+ bool enable_hfp_hf;
PA_LLIST_HEAD(pa_dbus_pending, pending);
};
@@ -786,15 +787,24 @@ static void profile_done(pa_bluetooth_ba
}
}
+static void native_backend_apply_profile_registration_change(pa_bluetooth_backend *native_backend, bool enable_hs_role) {
+ if (enable_hs_role) {
+ profile_init(native_backend, PA_BLUETOOTH_PROFILE_HFP_AG);
+ if (native_backend->enable_hfp_hf)
+ profile_init(native_backend, PA_BLUETOOTH_PROFILE_HFP_HF);
+ } else {
+ profile_done(native_backend, PA_BLUETOOTH_PROFILE_HFP_AG);
+ if (native_backend->enable_hfp_hf)
+ profile_done(native_backend, PA_BLUETOOTH_PROFILE_HFP_HF);
+ }
+}
+
void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backend *native_backend, bool enable_hs_role) {
if (enable_hs_role == native_backend->enable_hs_role)
return;
- if (enable_hs_role)
- profile_init(native_backend, PA_BLUETOOTH_PROFILE_HFP_AG);
- else
- profile_done(native_backend, PA_BLUETOOTH_PROFILE_HFP_AG);
+ native_backend_apply_profile_registration_change(native_backend, enable_hs_role);
native_backend->enable_hs_role = enable_hs_role;
}
@@ -818,12 +828,12 @@ pa_bluetooth_backend *pa_bluetooth_nativ
backend->discovery = y;
backend->enable_hs_role = enable_hs_role;
+ backend->enable_hfp_hf = pa_bluetooth_discovery_get_enable_native_hfp_hf(y);
+
+ if (backend->enable_hs_role)
+ native_backend_apply_profile_registration_change(backend, true);
- if (enable_hs_role)
- profile_init(backend, PA_BLUETOOTH_PROFILE_HFP_AG);
profile_init(backend, PA_BLUETOOTH_PROFILE_HSP_HS);
- if (pa_bluetooth_discovery_get_enable_native_hfp_hf(y))
- profile_init(backend, PA_BLUETOOTH_PROFILE_HFP_HF);
return backend;
}
@@ -834,10 +844,9 @@ void pa_bluetooth_native_backend_free(pa
pa_dbus_free_pending_list(&backend->pending);
if (backend->enable_hs_role)
- profile_done(backend, PA_BLUETOOTH_PROFILE_HFP_AG);
+ native_backend_apply_profile_registration_change(backend, false);
+
profile_done(backend, PA_BLUETOOTH_PROFILE_HSP_HS);
- if (pa_bluetooth_discovery_get_enable_native_hfp_hf(backend->discovery))
- profile_done(backend, PA_BLUETOOTH_PROFILE_HFP_HF);
pa_dbus_connection_unref(backend->connection);
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -1040,14 +1040,16 @@ void pa_bluetooth_discovery_set_ofono_ru
if (y->headset_backend != HEADSET_BACKEND_AUTO)
return;
- /* If ofono starts running, all devices that might be connected to the HS role
+ pa_bluetooth_native_backend_enable_hs_role(y->native_backend, !is_running);
+
+ /* If ofono starts running, all devices that might be connected to the HS roles or HFP AG role
* need to be disconnected, so that the devices can be handled by ofono */
if (is_running) {
void *state;
pa_bluetooth_device *d;
PA_HASHMAP_FOREACH(d, y->devices, state) {
- if (device_supports_profile(d, PA_BLUETOOTH_PROFILE_HFP_AG)) {
+ if (device_supports_profile(d, PA_BLUETOOTH_PROFILE_HFP_AG) || device_supports_profile(d, PA_BLUETOOTH_PROFILE_HFP_HF)) {
DBusMessage *m;
pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, d->path, "org.bluez.Device1", "Disconnect"));
@@ -1057,8 +1059,6 @@ void pa_bluetooth_discovery_set_ofono_ru
}
}
}
-
- pa_bluetooth_native_backend_enable_hs_role(y->native_backend, !is_running);
}
static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata) {
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -1914,7 +1914,7 @@ static pa_card_profile *create_card_prof
break;
case PA_BLUETOOTH_PROFILE_HSP_HS:
- cp = pa_card_profile_new(name, _("Headset Head Unit (HSP)"), sizeof(pa_bluetooth_profile_t));
+ cp = pa_card_profile_new(name, _("Headset Head Unit (HSP/HFP)"), sizeof(pa_bluetooth_profile_t));
cp->priority = 30;
cp->n_sinks = 1;
cp->n_sources = 1;