All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] transport: Fix not always being able to Acquire when linked
@ 2024-06-05 19:56 Luiz Augusto von Dentz
  2024-06-05 21:43 ` [BlueZ,v1] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2024-06-05 19:56 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If a linked transport becomes ready and sets an fd it means it can be
acquired via Acquire/TryAcquire methods but that shall also be valid for
linked transports as well since they share the same fd/IO it can already
be transferred despite the state of the stream.

Fixes: https://github.com/bluez/bluez/issues/862
---
 profiles/audio/transport.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 5b11bfeb6ab6..64d38ae669da 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -1492,11 +1492,20 @@ static guint transport_bap_resume(struct media_transport *transport,
 
 	if (!bap->stream)
 		return 0;
+
 	if (bap->resume_id)
-		return 0;
+		return bap->resume_id;
 
 	bap_update_links(transport);
 
+	/* If there is already an fd set consider it ready and proceed to
+	 * complete the resume process.
+	 */
+	if (transport->fd >= 0) {
+		bap->resume_id = g_idle_add(bap_resume_complete_cb, transport);
+		return bap->resume_id;
+	}
+
 	switch (bt_bap_stream_get_state(bap->stream)) {
 	case BT_BAP_STREAM_STATE_ENABLING:
 		bap_enable_complete(bap->stream, 0x00, 0x00, owner);
@@ -1671,6 +1680,22 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
 	g_io_channel_unref(chan);
 
 	media_transport_set_fd(transport, fd, imtu, omtu);
+
+	/* If the transport is linked update the fd in the link as well as they
+	 * share the same io channel.
+	 */
+	if (bap->linked) {
+		struct bt_bap_stream *link = bt_bap_stream_io_get_link(stream);
+
+		if (link) {
+			struct media_transport *t;
+
+			t = find_transport_by_bap_stream(link);
+			if (t)
+				media_transport_set_fd(t, fd, imtu, omtu);
+		}
+	}
+
 	transport_update_playing(transport, TRUE);
 
 done:
-- 
2.45.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-05 21:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 19:56 [PATCH BlueZ v1] transport: Fix not always being able to Acquire when linked Luiz Augusto von Dentz
2024-06-05 21:43 ` [BlueZ,v1] " bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.