[pulseaudio-discuss] [PATCH v1 3/3] bluetooth: Request headset audio during profile switch

Mikel Astiz mikel.astiz.oss at gmail.com
Mon Dec 3 02:03:59 PST 2012


From: Mikel Astiz <mikel.astiz at bmw-carit.de>

When a headset is having a profile switch, we can either leave the
SCO state unmodified (as it was before this patch) or we can
alternatively request it (as older versions of PA).

This patch tries to avoid a potential regression in case a module
such as module-suspend-on-idle is not present, due to the provided
resume-on-running policy. Without this patch, and without such a policy,
the sink and sources would stay suspended until the user manually
performed another profile switch (i.e. hsp->off->hsp).

There are several other solutions currently being discussed as a longer
term solution, some of which require extendind the core. This patch is
therefore proposed as a short-term workaround to avoid the regression.
---
 src/modules/bluetooth/module-bluetooth-device.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index b5ab7a1..6c0c746 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1743,7 +1743,7 @@ static int add_sink(struct userdata *u) {
             switch (u->profile) {
                 case PROFILE_A2DP:
                 case PROFILE_HSP:
-                    data.suspend_cause = PA_SUSPEND_IDLE;
+                    pa_assert_not_reached(); /* Profile switch should have failed */
                     break;
                 case PROFILE_HFGW:
                     data.suspend_cause = PA_SUSPEND_USER;
@@ -1818,7 +1818,7 @@ static int add_source(struct userdata *u) {
         if (!bt_transport_is_acquired(u))
             switch (u->profile) {
                 case PROFILE_HSP:
-                    data.suspend_cause = PA_SUSPEND_IDLE;
+                    pa_assert_not_reached(); /* Profile switch should have failed */
                     break;
                 case PROFILE_A2DP_SOURCE:
                 case PROFILE_HFGW:
@@ -2011,7 +2011,10 @@ static int setup_transport(struct userdata *u) {
     u->transport_removed_slot = pa_hook_connect(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED], PA_HOOK_NORMAL,
                                                 (pa_hook_cb_t) transport_removed_cb, u);
 
-    bt_transport_acquire(u, FALSE);
+    if (u->profile == PROFILE_A2DP_SOURCE || u->profile == PROFILE_HFGW)
+        bt_transport_acquire(u, FALSE); /* In case of error, the sink/sources will be created suspended */
+    else if (bt_transport_acquire(u, TRUE) < 0)
+        return -1; /* We need to fail here until the interactions with module-suspend-on-idle and alike get improved */
 
     bt_transport_config(u);
 
-- 
1.7.11.7



More information about the pulseaudio-discuss mailing list