Diff between 9cb73c97f84aba73eb1f279c593c117aff868987 and 41599b1d3b6715760a28e74eced68c704c6617eb

Changed Files

File Additions Deletions Status
android/a2dp.c +23 -2 modified

Full Patch

diff --git a/android/a2dp.c b/android/a2dp.c
index 6088438..32b6aa3 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -178,9 +178,30 @@ static uint8_t bt_a2dp_connect(struct hal_cmd_a2dp_connect *cmd, uint16_t len)
 static uint8_t bt_a2dp_disconnect(struct hal_cmd_a2dp_connect *cmd,
 								uint16_t len)
 {
-	DBG("Not Implemented");
+	struct a2dp_device *dev;
+	GSList *l;
+	bdaddr_t dst;
+
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr(&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(devices, &dst, device_cmp);
+	if (!l)
+		return HAL_STATUS_FAILED;
+
+	dev = l->data;
 
-	return HAL_STATUS_FAILED;
+	/* Wait signaling channel to HUP */
+	if (dev->io)
+		g_io_channel_shutdown(dev->io, TRUE, NULL);
+
+	bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTING);
+
+	return HAL_STATUS_SUCCESS;
 }
 
 void bt_a2dp_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)