OSDN Git Service

android/a2dp: Add initial implementation of HAL_OP_A2DP_DISCONNECT
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 14 Nov 2013 10:18:21 +0000 (12:18 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 14 Nov 2013 12:25:39 +0000 (14:25 +0200)
android/a2dp.c

index 6088438..32b6aa3 100644 (file)
@@ -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)