From c4c4de532d3837fcc42a50536130a14ed48f5153 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Date: Wed, 10 Sep 2014 11:48:30 +0200 Subject: [PATCH] bluetooth: Implement transport release for hf_audio_agent transports --- src/modules/bluetooth/backend-ofono.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c index 518e775db..bc92f4a08 100644 --- a/src/modules/bluetooth/backend-ofono.c +++ b/src/modules/bluetooth/backend-ofono.c @@ -188,6 +188,22 @@ static int hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool opti } static void hf_audio_agent_transport_release(pa_bluetooth_transport *t) { + struct hf_audio_card *card = t->userdata; + + pa_assert(card); + + if (t->state <= PA_BLUETOOTH_TRANSPORT_STATE_IDLE) { + pa_log_info("Transport %s already released", t->path); + return; + } + + if (card->fd < 0) + return; + + /* shutdown to make sure connection is dropped immediately */ + shutdown(card->fd, SHUT_RDWR); + close(card->fd); + card->fd = -1; } static void hf_audio_agent_card_found(pa_bluetooth_backend *backend, const char *path, DBusMessageIter *props_i) { -- 2.34.1