diff --git a/android/a2dp.c b/android/a2dp.c
index a9e7c65..55a433e 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
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)
bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTED);
- a2dp_device_free(dev);
-
return FALSE;
}
if (err) {
bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTED);
error("%s", err->message);
- a2dp_device_free(dev);
return;
}
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("");
if (notification_sk < 0)
return;
+ g_slist_foreach(devices, a2dp_device_disconnected, NULL);
+ devices = NULL;
+
notification_sk = -1;
bt_adapter_remove_record(record_id);