[pulseaudio-discuss] [PATCH] bluez5: Do not suspend on no -> unknown profile transitions

David Henningsson david.henningsson at canonical.com
Fri Dec 19 01:24:47 PST 2014


In case a transport is currently disconnected and transitions to
idle, that should not count as a "remote hang up" event.

Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---

When used together with Tanu's module-card-restore patch, then the a2dp profile could
successfully be restored when PA starts up.

That said, I somewhat prefer my own version which never sets the profile to off. Just like
an available port does not cause the backend to switch away from it, (this logic is up to
module-switch-on-port-available), unavailable profiles should work the same way IMO.

 src/modules/bluetooth/module-bluez5-device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index e6a8071..995e550 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -1968,11 +1968,13 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
     bool release = false;
     pa_card_profile *cp;
     pa_device_port *port;
+    pa_available_t oldavail;
 
     pa_assert(u);
     pa_assert(t);
     pa_assert_se(cp = pa_hashmap_get(u->card->profiles, pa_bluetooth_profile_to_string(t->profile)));
 
+    oldavail = cp->available;
     pa_card_profile_set_available(cp, transport_state_to_availability(t->state));
 
     /* Update port availability */
@@ -1983,7 +1985,7 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
 
     /* Acquire or release transport as needed */
     acquire = (t->state == PA_BLUETOOTH_TRANSPORT_STATE_PLAYING && u->profile == t->profile);
-    release = (t->state != PA_BLUETOOTH_TRANSPORT_STATE_PLAYING && u->profile == t->profile);
+    release = (oldavail != PA_AVAILABLE_NO && t->state != PA_BLUETOOTH_TRANSPORT_STATE_PLAYING && u->profile == t->profile);
 
     if (acquire && transport_acquire(u, true) >= 0) {
         if (u->source) {
-- 
2.1.3



More information about the pulseaudio-discuss mailing list