[pulseaudio-discuss] [PATCH v0 06/16] bluetooth: Release transport in stop_thread()

Mikel Astiz mikel.astiz.oss at gmail.com
Fri Sep 28 08:45:30 PDT 2012


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

Avoid duplicated code by releasing the transport inside stop_thread(),
along with the rest of the thread-related cleanup.
---
 src/modules/bluetooth/module-bluetooth-device.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index f1af964..2635e93 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1990,13 +1990,6 @@ static int setup_transport(struct userdata *u) {
         return -1;
     }
 
-    /* release transport if exist */
-    if (u->transport) {
-        bt_transport_release(u);
-        pa_xfree(u->transport);
-        u->transport = NULL;
-    }
-
     /* check if profile has a transport */
     t = pa_bluetooth_device_get_transport(d, u->profile);
     if (t == NULL) {
@@ -2069,6 +2062,12 @@ static void stop_thread(struct userdata *u) {
         u->hsp.nrec_changed_slot = NULL;
     }
 
+    if (u->transport) {
+        bt_transport_release(u);
+        pa_xfree(u->transport);
+        u->transport = NULL;
+    }
+
     if (u->sink) {
         if (u->profile == PROFILE_HSP) {
             k = pa_sprintf_malloc("bluetooth-device@%p", (void*) u->sink);
@@ -2233,12 +2232,6 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
 
     stop_thread(u);
 
-    if (u->profile != PROFILE_OFF && u->transport) {
-        bt_transport_release(u);
-        pa_xfree(u->transport);
-        u->transport = NULL;
-    }
-
     if (USE_SCO_OVER_PCM(u))
         restore_sco_volume_callbacks(u);
 
@@ -2743,11 +2736,6 @@ void pa__done(pa_module *m) {
     pa_xfree(u->address);
     pa_xfree(u->path);
 
-    if (u->transport) {
-        bt_transport_release(u);
-        pa_xfree(u->transport);
-    }
-
     if (u->discovery)
         pa_bluetooth_discovery_unref(u->discovery);
 
-- 
1.7.11.4



More information about the pulseaudio-discuss mailing list