diff mbox series

[BlueZ,14/14] transport: Unlink broadcast transport at release

Message ID 20241024110223.77254-15-iulia.tanasescu@nxp.com (mailing list archive)
State Superseded
Headers show
Series bap: Add support for Broadcast Sink AC 13 | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS

Commit Message

Iulia Tanasescu Oct. 24, 2024, 11:02 a.m. UTC
This updates broadcast transport release to unlink stream from all its
links.
---
 profiles/audio/transport.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
diff mbox series

Patch

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index bb2ce8a4a..5646b2004 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -1779,10 +1779,45 @@  static guint transport_bap_resume(struct media_transport *transport,
 	return id;
 }
 
+static void update_links(void *data, void *user_data)
+{
+	struct bt_bap_stream *link = data;
+	struct media_transport *transport;
+
+	transport = find_transport_by_bap_stream(link);
+	if (!transport) {
+		error("Unable to find transport");
+		return;
+	}
+
+	bap_update_links(transport);
+}
+
+static void transport_unlink(void *data, void *user_data)
+{
+	struct bt_bap_stream *link = data;
+	struct bt_bap_stream *stream = user_data;
+	struct media_transport *transport;
+
+	transport = find_transport_by_bap_stream(link);
+	if (!transport) {
+		error("Unable to find transport");
+		return;
+	}
+
+	bt_bap_stream_io_unlink(link, stream);
+
+	bap_update_links(transport);
+
+	/* Emit property changed for all remaining links */
+	queue_foreach(bt_bap_stream_io_get_links(link), update_links, NULL);
+}
+
 static guint transport_bap_suspend(struct media_transport *transport,
 				struct media_owner *owner)
 {
 	struct bap_transport *bap = transport->data;
+	struct queue *links = bt_bap_stream_io_get_links(bap->stream);
 	bt_bap_stream_func_t func = NULL;
 	guint id;
 
@@ -1794,6 +1829,10 @@  static guint transport_bap_suspend(struct media_transport *transport,
 	else
 		transport_set_state(transport, TRANSPORT_STATE_IDLE);
 
+	if (bt_bap_stream_get_type(bap->stream) == BT_BAP_STREAM_TYPE_BCAST)
+		/* Unlink stream from all its links */
+		queue_foreach(links, transport_unlink, bap->stream);
+
 	bap_update_links(transport);
 
 	id = bt_bap_stream_disable(bap->stream, bap->linked, func, owner);