From 8560b495bda60c6876927280ec34cbf0ddd29fc8 Mon Sep 17 00:00:00 2001 From: Mikel Astiz Date: Fri, 28 Sep 2012 17:45:30 +0200 Subject: [PATCH] bluetooth: Release transport in stop_thread() Avoid duplicated code by releasing the transport inside stop_thread(), along with the rest of the thread-related cleanup. --- .../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 0f3977280..e55c8c642 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1987,13 +1987,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) { @@ -2066,6 +2059,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); @@ -2230,12 +2229,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); @@ -2740,11 +2733,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);