[pulseaudio-commits] 3 commits - src/modules

Tanu Kaskinen tanuk at kemper.freedesktop.org
Mon Dec 3 17:11:33 PST 2012


 src/modules/bluetooth/module-bluetooth-device.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

New commits:
commit bbb47c67bb4434d752f2225d7f1744721c6e6054
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date:   Mon Dec 3 11:03:59 2012 +0100

    bluetooth: Request headset audio during profile switch
    
    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.

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index f8315e1..093550e 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);
 

commit 01435e613417258f35e406f1ab95042b1c48b832
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date:   Mon Dec 3 11:03:58 2012 +0100

    bluetooth: Do not setup stream before thread starts
    
    bt_transport_acquire() might get called from the main thread, in case
    the IO thread hasn't been started yet. In this case, we should not call
    setup_stream() since this is going to be called in the beginning of
    thread_func().

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 7d89f6c..f8315e1 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -426,6 +426,10 @@ static int bt_transport_acquire(struct userdata *u, pa_bool_t start) {
         return 0;
 
 done:
+    /* If thread is still about to start, the stream will be set up in the beginning of thread_func() */
+    if (u->thread == NULL)
+        return 0;
+
     setup_stream(u);
 
     return 0;

commit 1dcdb96ee5384d16644271233ff93dbdd2e6c158
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date:   Mon Dec 3 11:03:57 2012 +0100

    bluetooth: Trivially refactor to call setup_stream() directly
    
    If the transport is already acquired and the stream needs to be started,
    call setup_stream() directly instead of bt_transport_acquire(u, TRUE).
    Both calls are identical in these conditions, with the exception of the
    log trace which has now been moved to setup_stream().

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 506a479..7d89f6c 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -284,6 +284,8 @@ static void setup_stream(struct userdata *u) {
     struct pollfd *pollfd;
     int one;
 
+    pa_log_info("Transport %s resuming", u->transport->path);
+
     bt_transport_config_mtu(u);
 
     pa_make_fd_nonblock(u->stream_fd);
@@ -424,7 +426,6 @@ static int bt_transport_acquire(struct userdata *u, pa_bool_t start) {
         return 0;
 
 done:
-    pa_log_info("Transport %s resuming", u->transport->path);
     setup_stream(u);
 
     return 0;
@@ -1045,7 +1046,7 @@ static void thread_func(void *userdata) {
 
     /* Setup the stream only if the transport was already acquired */
     if (bt_transport_is_acquired(u))
-        bt_transport_acquire(u, TRUE);
+        setup_stream(u);
 
     for (;;) {
         struct pollfd *pollfd;



More information about the pulseaudio-commits mailing list