From fcaef8285aec9d22764b8d41e6e1379f5cfd583f Mon Sep 17 00:00:00 2001 From: Mikel Astiz Date: Fri, 28 Sep 2012 17:45:31 +0200 Subject: [PATCH] bluetooth: Unlink sink-sources in stop_thread() Avoid duplicated code by moving the unlinking of sinks and sources to stop_thread(). After all, they need to be unlinked when the thread is stopped. --- .../bluetooth/module-bluetooth-device.c | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index e55c8c642..4a88a081b 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -2033,6 +2033,12 @@ static void stop_thread(struct userdata *u) { pa_assert(u); + if (u->sink && !USE_SCO_OVER_PCM(u)) + pa_sink_unlink(u->sink); + + if (u->source && !USE_SCO_OVER_PCM(u)) + pa_source_unlink(u->source); + if (u->thread) { pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL); pa_thread_free(u->thread); @@ -2213,20 +2219,12 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { } } - if (u->sink) { + if (u->sink) inputs = pa_sink_move_all_start(u->sink, NULL); - if (!USE_SCO_OVER_PCM(u)) - pa_sink_unlink(u->sink); - } - - if (u->source) { + if (u->source) outputs = pa_source_move_all_start(u->source, NULL); - if (!USE_SCO_OVER_PCM(u)) - pa_source_unlink(u->source); - } - stop_thread(u); if (USE_SCO_OVER_PCM(u)) @@ -2680,12 +2678,6 @@ void pa__done(pa_module *m) { if (!(u = m->userdata)) return; - if (u->sink && !USE_SCO_OVER_PCM(u)) - pa_sink_unlink(u->sink); - - if (u->source && !USE_SCO_OVER_PCM(u)) - pa_source_unlink(u->source); - stop_thread(u); if (USE_SCO_OVER_PCM(u))