OSDN Git Service

audio/A2DP: Add implemention of audio Close Stream command
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 9 Jan 2014 15:27:24 +0000 (17:27 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 13 Jan 2014 12:33:16 +0000 (14:33 +0200)
android/a2dp.c

index b26d727..ece5e47 100644 (file)
@@ -752,8 +752,29 @@ static void bt_stream_open(const void *buf, uint16_t len)
 
 static void bt_stream_close(const void *buf, uint16_t len)
 {
-       DBG("Not Implemented");
+       const struct audio_cmd_close_stream *cmd = buf;
+       struct a2dp_setup *setup;
+       int err;
 
+       DBG("");
+
+       setup = find_setup(cmd->id);
+       if (!setup) {
+               error("Unable to find stream for endpoint %u", cmd->id);
+               goto failed;
+       }
+
+       err = avdtp_close(setup->dev->session, setup->stream, FALSE);
+       if (err < 0) {
+               error("avdtp_close: %s", strerror(-err));
+               goto failed;
+       }
+
+       audio_ipc_send_rsp(AUDIO_OP_CLOSE_STREAM, AUDIO_STATUS_SUCCESS);
+
+       return;
+
+failed:
        audio_ipc_send_rsp(AUDIO_OP_CLOSE_STREAM, AUDIO_STATUS_FAILED);
 }