* [PATCH BlueZ] android/a2dp: Cleanup devices on unregister
@ 2013-11-20 9:39 Luiz Augusto von Dentz
2013-11-21 8:16 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2013-11-20 9:39 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This cleanup any existing devices in bt_a2dp_unregister
---
android/a2dp.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/android/a2dp.c b/android/a2dp.c
index a9e7c65..55a433e 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -109,6 +109,11 @@ static void bt_a2dp_notify_state(struct a2dp_device *dev, uint8_t state)
ipc_send(notification_sk, HAL_SERVICE_ID_A2DP,
HAL_EV_A2DP_CONN_STATE, sizeof(ev), &ev, -1);
+
+ if (state != HAL_A2DP_STATE_DISCONNECTED)
+ return;
+
+ a2dp_device_free(dev);
}
static gboolean watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
@@ -117,8 +122,6 @@ static gboolean watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTED);
- a2dp_device_free(dev);
-
return FALSE;
}
@@ -130,7 +133,6 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err,
if (err) {
bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTED);
error("%s", err->message);
- a2dp_device_free(dev);
return;
}
@@ -364,6 +366,13 @@ bool bt_a2dp_register(int sk, const bdaddr_t *addr)
return true;
}
+static void a2dp_device_disconnected(gpointer data, gpointer user_data)
+{
+ struct a2dp_device *dev = data;
+
+ bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTED);
+}
+
void bt_a2dp_unregister(void)
{
DBG("");
@@ -371,6 +380,9 @@ void bt_a2dp_unregister(void)
if (notification_sk < 0)
return;
+ g_slist_foreach(devices, a2dp_device_disconnected, NULL);
+ devices = NULL;
+
notification_sk = -1;
bt_adapter_remove_record(record_id);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-21 8:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 9:39 [PATCH BlueZ] android/a2dp: Cleanup devices on unregister Luiz Augusto von Dentz
2013-11-21 8:16 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox