diff mbox series

[v2,9/9] avdtp: Add support for MSFT offload close command

Message ID 20211119094235.2432-9-kiran.k@intel.com
State New
Headers show
Series [v2,1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set | expand

Commit Message

K, Kiran Nov. 19, 2021, 9:42 a.m. UTC
In a2dp offload use case, send MSFT avdtp close
command followed by remote AVDTP close command.
---
 profiles/audio/avdtp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index c0217f272b2c..7619c167e6cf 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2945,6 +2945,24 @@  static gboolean avdtp_start_resp(struct avdtp *session,
 	return TRUE;
 }
 
+static gboolean msft_avdtp_close(struct avdtp_stream *stream)
+{
+	int sock;
+	struct bt_msft cmd;
+
+	if (!stream->io)
+		return FALSE;
+
+	sock = g_io_channel_unix_get_fd(stream->io);
+
+	cmd.sub_opcode = 0x0b;
+
+	if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT, &cmd, 1))
+		return FALSE;
+
+	return TRUE;
+}
+
 static gboolean avdtp_close_resp(struct avdtp *session,
 					struct avdtp_stream *stream,
 					struct seid_rej *resp, int size)
@@ -2953,6 +2971,9 @@  static gboolean avdtp_close_resp(struct avdtp *session,
 
 	avdtp_sep_set_state(session, sep, AVDTP_STATE_CLOSING);
 
+	if (session->use_offload)
+		msft_avdtp_close(stream);
+
 	close_stream(stream);
 
 	return TRUE;