[pulseaudio] 01/02: Add more bluez5 + ofono + HFP patches
David Henningsson
diwic-guest at moszumanska.debian.org
Thu Dec 17 09:36:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
diwic-guest pushed a commit to branch ubuntu
in repository pulseaudio.
commit fae66558236fc1112fc670a02265e27a3e15f2eb
Author: David Henningsson <david.henningsson at canonical.com>
Date: Thu Dec 17 10:12:43 2015 +0100
Add more bluez5 + ofono + HFP patches
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
debian/changelog | 2 +
...luez5-add-guards-to-prevent-HFP-and-HSP-c.patch | 49 +++++++
...luez5-don-t-reactivate-default-profile-wh.patch | 29 ++++
...Further-fixes-for-HFP-A2DP-with-BlueZ-5.x.patch | 156 +++++++++++++++++++++
debian/patches/series | 3 +
5 files changed, 239 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 0abb266..b55389a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ pulseaudio (1:7.1-1ubuntu3) UNRELEASED; urgency=medium
* trust-store: Update translation string
* Cherrypick upstream patches to allow client.conf.d
and daemon.conf.d
+ * debian/patches/0508/0509/0510*.patches
+ - More patches for bluez5 + ofono + HFP support
-- David Henningsson <david.henningsson at canonical.com> Mon, 30 Nov 2015 16:43:53 +0100
diff --git a/debian/patches/0508-bluetooth-bluez5-add-guards-to-prevent-HFP-and-HSP-c.patch b/debian/patches/0508-bluetooth-bluez5-add-guards-to-prevent-HFP-and-HSP-c.patch
new file mode 100644
index 0000000..e96ca34
--- /dev/null
+++ b/debian/patches/0508-bluetooth-bluez5-add-guards-to-prevent-HFP-and-HSP-c.patch
@@ -0,0 +1,49 @@
+From d654af2e527d21a60b414c6649988454cf01068d Mon Sep 17 00:00:00 2001
+From: Simon Fels <simon.fels at canonical.com>
+Date: Thu, 26 Nov 2015 07:30:51 +0100
+Subject: [PATCH] bluetooth: bluez5: add guards to prevent HFP and HSP
+ connected together
+
+---
+ src/modules/bluetooth/backend-native.c | 18 +++++++++++++++++-
+ 1 file changed, 17 insertions(+), 1 deletion(-)
+
+diff --git a/src/modules/bluetooth/backend-native.c b/src/modules/bluetooth/backend-native.c
+index 8d9d95c..1f65146 100644
+--- a/src/modules/bluetooth/backend-native.c
++++ b/src/modules/bluetooth/backend-native.c
+@@ -340,6 +340,23 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
+ goto fail;
+ }
+
++ p = PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT;
++ /* We might have support for HSP/HFP at the same time and therefor
++ * need to check if the other side is already setup or not. If it
++ * is we fail here as having both active at the same time is not
++ * supported */
++ if (d->transports[p]) {
++ pa_log_error("Transport for profile %s already registered.",
++ pa_bluetooth_profile_to_string(p));
++ goto fail;
++ }
++
++ if (pa_hashmap_get(d->uuids, PA_BLUETOOTH_UUID_HFP_HF)) {
++ pa_log_error("Remote device %s supports HFP as well which is preferred over HSP. Aborting.",
++ d->address);
++ 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);
+@@ -349,7 +366,6 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
+
+ sender = dbus_message_get_sender(m);
+
+- p = PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT;
+ pathfd = pa_sprintf_malloc ("%s/fd%d", path, fd);
+ d->transports[p] = t = pa_bluetooth_transport_new(d, sender, pathfd, p, NULL, 0);
+ pa_xfree(pathfd);
+--
+2.1.4
+
diff --git a/debian/patches/0509-bluetooth-bluez5-don-t-reactivate-default-profile-wh.patch b/debian/patches/0509-bluetooth-bluez5-don-t-reactivate-default-profile-wh.patch
new file mode 100644
index 0000000..04756b8
--- /dev/null
+++ b/debian/patches/0509-bluetooth-bluez5-don-t-reactivate-default-profile-wh.patch
@@ -0,0 +1,29 @@
+From f8213ddec83cd0780ae77ad423581d9a65857d1f Mon Sep 17 00:00:00 2001
+From: Simon Fels <simon.fels at canonical.com>
+Date: Thu, 26 Nov 2015 08:54:20 +0100
+Subject: [PATCH] bluetooth: bluez5: don't reactivate default profile when off
+ is active
+
+---
+ src/modules/bluetooth/module-bluez5-device.c | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
+index b4f81cd..8c5a9cc 100644
+--- a/src/modules/bluetooth/module-bluez5-device.c
++++ b/src/modules/bluetooth/module-bluez5-device.c
+@@ -2323,11 +2323,6 @@ static pa_hook_result_t transport_state_changed_cb(pa_bluetooth_discovery *y, pa
+ if (t->device == u->device)
+ handle_transport_state_change(u, t);
+
+- /* For the case that we've currently the 'off' profile set we need to move
+- * on to a possible configured default profile. */
+- if (u->profile == PA_BLUETOOTH_PROFILE_OFF && pa_bluetooth_device_any_transport_connected(u->device) && u->default_profile)
+- pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, u->default_profile), false);
+-
+ return PA_HOOK_OK;
+ }
+
+--
+2.5.0
+
diff --git a/debian/patches/0510-Further-fixes-for-HFP-A2DP-with-BlueZ-5.x.patch b/debian/patches/0510-Further-fixes-for-HFP-A2DP-with-BlueZ-5.x.patch
new file mode 100644
index 0000000..3f6606e
--- /dev/null
+++ b/debian/patches/0510-Further-fixes-for-HFP-A2DP-with-BlueZ-5.x.patch
@@ -0,0 +1,156 @@
+From bf107ef8e9bfda2f2609dfedd717726f387ae8a6 Mon Sep 17 00:00:00 2001
+From: Simon Fels <simon.fels at canonical.com>
+Date: Mon, 30 Nov 2015 13:57:44 +0100
+Subject: [PATCH] Further fixes for HFP/A2DP with BlueZ 5.x
+
+---
+ src/modules/bluetooth/backend-native.c | 3 +-
+ src/modules/bluetooth/bluez5-util.c | 6 ++++
+ src/modules/bluetooth/bluez5-util.h | 2 ++
+ src/modules/bluetooth/module-bluez5-device.c | 44 +++++++++++++++++++++++-----
+ 4 files changed, 46 insertions(+), 9 deletions(-)
+
+diff --git a/src/modules/bluetooth/backend-native.c b/src/modules/bluetooth/backend-native.c
+index 1f65146..442bb64 100644
+--- a/src/modules/bluetooth/backend-native.c
++++ b/src/modules/bluetooth/backend-native.c
+@@ -351,7 +351,8 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
+ goto fail;
+ }
+
+- if (pa_hashmap_get(d->uuids, PA_BLUETOOTH_UUID_HFP_HF)) {
++ if (pa_hashmap_get(d->uuids, PA_BLUETOOTH_UUID_HFP_HF) &&
++ pa_bluetooth_device_is_transport_connected(d, PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT)) {
+ pa_log_error("Remote device %s supports HFP as well which is preferred over HSP. Aborting.",
+ d->address);
+ goto fail;
+diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
+index 747384a..3acc4a5 100644
+--- a/src/modules/bluetooth/bluez5-util.c
++++ b/src/modules/bluetooth/bluez5-util.c
+@@ -299,6 +299,12 @@ bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d) {
+ return false;
+ }
+
++bool pa_bluetooth_device_is_transport_connected(const pa_bluetooth_device *d, pa_bluetooth_profile_t profile) {
++ pa_assert(d);
++
++ return d->transports[profile] && d->transports[profile]->state == PA_BLUETOOTH_TRANSPORT_STATE_IDLE;
++}
++
+ static int transport_state_from_string(const char* value, pa_bluetooth_transport_state_t *state) {
+ pa_assert(value);
+ pa_assert(state);
+diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h
+index 3f97de7..9180263 100644
+--- a/src/modules/bluetooth/bluez5-util.h
++++ b/src/modules/bluetooth/bluez5-util.h
+@@ -144,6 +144,8 @@ void pa_bluetooth_transport_unlink(pa_bluetooth_transport *t);
+ void pa_bluetooth_transport_free(pa_bluetooth_transport *t);
+
+ bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d);
++bool pa_bluetooth_device_is_transport_connected(const pa_bluetooth_device *d, pa_bluetooth_profile_t profile);
++
+
+ pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_path(pa_bluetooth_discovery *y, const char *path);
+ pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_discovery *y, const char *remote, const char *local);
+diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
+index 8c5a9cc..b4b627a 100644
+--- a/src/modules/bluetooth/module-bluez5-device.c
++++ b/src/modules/bluetooth/module-bluez5-device.c
+@@ -165,6 +165,8 @@ struct userdata {
+ char *default_profile;
+ bool transport_acquire_pending;
+ pa_io_event *stream_event;
++
++ pa_defer_event *set_default_profile_event;
+ };
+
+ typedef enum pa_bluetooth_form_factor {
+@@ -2085,13 +2087,6 @@ static int set_profile_cb(pa_card *c, pa_card_profile *new_profile) {
+
+ if (!d->transports[*p] || d->transports[*p]->state <= PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED) {
+ pa_log_warn("Refused to switch profile to %s: Not connected", new_profile->name);
+-
+- /* For the rare case that we were requested to switch to A2DP
+- * but that failed (due the profile got disconnected) we switch
+- * to off */
+- if (*p == PA_BLUETOOTH_PROFILE_A2DP_SINK)
+- pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
+-
+ return -PA_ERR_IO;
+ }
+ }
+@@ -2209,6 +2204,10 @@ static int add_card(struct userdata *u) {
+ u->card->active_profile = pa_hashmap_get(u->card->profiles, "off");
+ u->card->save_profile = false;
+ }
++ else {
++ pa_xfree(u->default_profile);
++ u->default_profile = NULL;
++ }
+
+ p = PA_CARD_PROFILE_DATA(u->card->active_profile);
+ u->profile = *p;
+@@ -2308,6 +2307,23 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
+ return PA_HOOK_OK;
+ }
+
++static void set_default_profile_cb(pa_mainloop_api *api, pa_defer_event *e, void *user_data) {
++ struct userdata *u = user_data;
++
++ pa_assert(u);
++
++ if (!u->default_profile)
++ return;
++
++ pa_log_debug("Setting default profile %s", u->default_profile);
++
++ pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, u->default_profile), false) >= 0);
++ pa_xfree(u->default_profile);
++ u->default_profile = NULL;
++
++ api->defer_enable(e, 0);
++}
++
+ /* Run from main thread */
+ static pa_hook_result_t transport_state_changed_cb(pa_bluetooth_discovery *y, pa_bluetooth_transport *t, struct userdata *u) {
+ pa_assert(t);
+@@ -2317,7 +2333,13 @@ static pa_hook_result_t transport_state_changed_cb(pa_bluetooth_discovery *y, pa
+ pa_bluetooth_profile_to_string(t->profile),
+ pa_bluetooth_transport_state_to_string(t->state));
+
+- if (t == u->transport && t->state <= PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
++ if (t->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT && t->state == PA_BLUETOOTH_TRANSPORT_STATE_PLAYING)
++ pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "headset_head_unit"), false) >= 0);
++
++ else if (u->profile == PA_BLUETOOTH_PROFILE_OFF && pa_bluetooth_device_any_transport_connected(u->device) && u->default_profile)
++ u->core->mainloop->defer_enable(u->set_default_profile_event, 1);
++
++ else if (t == u->transport && t->state <= PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
+ pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
+
+ if (t->device == u->device)
+@@ -2504,6 +2526,9 @@ int pa__init(pa_module* m) {
+ if (!(u->msg = pa_msgobject_new(bluetooth_msg)))
+ goto fail;
+
++ u->set_default_profile_event = u->core->mainloop->defer_new(u->core->mainloop, set_default_profile_cb, u);
++ u->core->mainloop->defer_enable(u->set_default_profile_event, 0);
++
+ u->msg->parent.process_msg = device_process_msg;
+ u->msg->card = u->card;
+
+@@ -2589,6 +2614,9 @@ void pa__done(pa_module *m) {
+ if (u->default_profile)
+ pa_xfree(u->default_profile);
+
++ if (u->set_default_profile_event)
++ u->core->mainloop->defer_free(u->set_default_profile_event);
++
+ pa_xfree(u);
+ }
+
+--
+2.5.0
+
diff --git a/debian/patches/series b/debian/patches/series
index 21955b1..b7e614a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -36,3 +36,6 @@
0505-bluetooth-bluez5-let-user-specify-a-default-profile-.patch
0506-bluetooth-bluez5-prevent-SCO-sink-source-to-be-suspe.patch
0507-bluetooth-bluez5-drop-save-restore-of-SCO-sink-sourc.patch
+0508-bluetooth-bluez5-add-guards-to-prevent-HFP-and-HSP-c.patch
+0509-bluetooth-bluez5-don-t-reactivate-default-profile-wh.patch
+0510-Further-fixes-for-HFP-A2DP-with-BlueZ-5.x.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-pulseaudio/pulseaudio.git
More information about the pkg-pulseaudio-devel
mailing list