diff mbox series

[BlueZ,9/9] transport: Trigger transport reacquire for multiple BISes sync

Message ID 20241004123523.1012743-10-vlad.pruteanu@nxp.com
State New
Headers show
Series Allow syncing to multiple BISes from the same BIG | expand

Commit Message

Vlad Pruteanu Oct. 4, 2024, 12:35 p.m. UTC
Once the transport is release, bap_stop_complete is called. If the
transport is part of a sync with multiple BISes, it needs to be
reacquired. Such a transport will have it's stream in the
BT_BAP_STREAM_STATE_PENDING state. Thus, transport_update_playing
with playing set to TRUE must be called. This will set the transport
state to BROADCASTING, so that the audio server will automatically
acquire it.
---
 profiles/audio/transport.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index e68695c39..4ea793a27 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -705,13 +705,16 @@  static DBusMessage *try_acquire(DBusConnection *conn, DBusMessage *msg,
 	return NULL;
 }
 
+static void transport_update_playing(struct media_transport *transport,
+							gboolean playing);
+
 static void bap_stop_complete(struct bt_bap_stream *stream,
 					uint8_t code, uint8_t reason,
 					void *user_data)
 {
-	struct media_owner *owner = user_data;
 	struct media_request *req;
-	struct media_transport *transport;
+	struct media_transport *transport = user_data;
+	struct media_owner *owner = transport->owner;
 
 	if (!owner)
 		return;
@@ -731,6 +734,11 @@  static void bap_stop_complete(struct bt_bap_stream *stream,
 		transport_set_state(transport, TRANSPORT_STATE_IDLE);
 		media_transport_remove_owner(transport);
 	}
+	if (bt_bap_stream_get_state(stream) == BT_BAP_STREAM_STATE_PENDING)
+		/* Transports with streams in this state should be reaquired as
+		 * part of a multiple BIS sync.
+		 */
+		transport_update_playing(transport, TRUE);
 }
 
 static void bap_disable_complete(struct bt_bap_stream *stream,
@@ -1707,7 +1715,8 @@  static guint transport_bap_suspend(struct media_transport *transport,
 
 	if (bt_bap_stream_get_type(bap->stream) == BT_BAP_STREAM_TYPE_BCAST) {
 		if (transport->owner == owner)
-			bap_disable_complete(bap->stream, 0x00, 0x00, owner);
+			bap_disable_complete(bap->stream, 0x00, 0x00,
+				transport);
 		return 0;
 	}