linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Update transport acquire/release flow for BAP bcast source
@ 2023-09-11  7:47 Silviu Florian Barbulescu
  2023-09-11  7:47 ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Silviu Florian Barbulescu
  2023-09-11  7:47 ` [PATCH 2/2] bap:Update transport acquire/release flow for " Silviu Florian Barbulescu
  0 siblings, 2 replies; 5+ messages in thread
From: Silviu Florian Barbulescu @ 2023-09-11  7:47 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, silviu.barbulescu,
	vlad.pruteanu, andrei.istodorescu, iulia.tanasescu, luiz.dentz

Update transport acquire/release flow for BAP broadcast source to 
fix failure on transport release, and second acquire

Silviu Florian Barbulescu (2):
  Update stream enable/disable flow for BAP broadcast source
  Update transport acquire/release flow for BAP broadcast source

 profiles/audio/bap.c       | 27 ++++++++++++-----
 profiles/audio/transport.c | 62 ++++++++++++++++++++++----------------
 src/shared/bap.c           | 51 ++++++++++++++++++++++---------
 src/shared/bap.h           |  2 ++
 4 files changed, 95 insertions(+), 47 deletions(-)


base-commit: df658c6c4ab5bd5ec4a8a3f8faa36e0d0a5f906a
-- 
2.34.1


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

* [PATCH 1/2] shared/bap:Update stream enable/disable flow bcast source
  2023-09-11  7:47 [PATCH 0/2] Update transport acquire/release flow for BAP bcast source Silviu Florian Barbulescu
@ 2023-09-11  7:47 ` Silviu Florian Barbulescu
  2023-09-11  9:26   ` Update transport acquire/release flow for BAP " bluez.test.bot
  2023-09-12 18:44   ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Luiz Augusto von Dentz
  2023-09-11  7:47 ` [PATCH 2/2] bap:Update transport acquire/release flow for " Silviu Florian Barbulescu
  1 sibling, 2 replies; 5+ messages in thread
From: Silviu Florian Barbulescu @ 2023-09-11  7:47 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, silviu.barbulescu,
	vlad.pruteanu, andrei.istodorescu, iulia.tanasescu, luiz.dentz

Update stream enable/disable flow for BAP broadcast source

---
 src/shared/bap.c | 51 +++++++++++++++++++++++++++++++++++-------------
 src/shared/bap.h |  2 ++
 2 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 1c43680c2..801716dd9 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -1331,6 +1331,11 @@ static void stream_set_state_broadcast(struct bt_bap_stream *stream,
 	ep->old_state = ep->state;
 	ep->state = state;
 
+	DBG(bap, "stream %p dir 0x%02x: %s -> %s", stream,
+			bt_bap_stream_get_dir(stream),
+			bt_bap_stream_statestr(stream->ep->old_state),
+			bt_bap_stream_statestr(stream->ep->state));
+
 	bt_bap_ref(bap);
 
 	for (entry = queue_get_entries(bap->state_cbs); entry;
@@ -1492,7 +1497,7 @@ static void ep_config_cb(struct bt_bap_stream *stream, int err)
 		return;
 
 	if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) {
-		stream_set_state_broadcast(stream, BT_BAP_STREAM_STATE_CONFIG);
+		stream_set_state_broadcast(stream, BT_BAP_STREAM_STATE_QOS);
 		return;
 	}
 
@@ -4698,13 +4703,19 @@ unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream,
 		break;
 	case BT_BAP_STREAM_TYPE_BCAST:
 		stream_set_state_broadcast(stream,
-					BT_BAP_STREAM_STATE_STREAMING);
+					BT_BAP_STREAM_STATE_CONFIG);
 		return 1;
 	}
 
 	return ret;
 }
 
+void bt_bap_stream_streaming(struct bt_bap_stream *stream)
+{
+		stream_set_state_broadcast(stream,
+					BT_BAP_STREAM_STATE_STREAMING);
+}
+
 unsigned int bt_bap_stream_start(struct bt_bap_stream *stream,
 					bt_bap_stream_func_t func,
 					void *user_data)
@@ -4779,24 +4790,36 @@ unsigned int bt_bap_stream_disable(struct bt_bap_stream *stream,
 		return 0;
 	}
 
-	memset(&disable, 0, sizeof(disable));
+	switch (bt_bap_stream_get_type(stream)) {
+	case BT_BAP_STREAM_TYPE_UCAST:
+		memset(&disable, 0, sizeof(disable));
 
-	disable.ase = stream->ep->id;
+		disable.ase = stream->ep->id;
 
-	iov.iov_base = &disable;
-	iov.iov_len = sizeof(disable);
+		iov.iov_base = &disable;
+		iov.iov_len = sizeof(disable);
 
-	req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func, user_data);
+		req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func,
+							user_data);
 
-	if (!bap_queue_req(stream->bap, req)) {
-		bap_req_free(req);
-		return 0;
-	}
+		if (!bap_queue_req(stream->bap, req)) {
+			bap_req_free(req);
+			return 0;
+		}
 
-	if (disable_links)
-		queue_foreach(stream->links, bap_stream_disable_link, NULL);
+		if (disable_links)
+			queue_foreach(stream->links, bap_stream_disable_link,
+							NULL);
 
-	return req->id;
+		return req->id;
+
+	case BT_BAP_STREAM_TYPE_BCAST:
+		stream_set_state_broadcast(stream,
+					BT_BAP_STREAM_STATE_RELEASING);
+		return 1;
+	}
+
+	return 0;
 }
 
 unsigned int bt_bap_stream_stop(struct bt_bap_stream *stream,
diff --git a/src/shared/bap.h b/src/shared/bap.h
index edb5c1bed..d3c9b241e 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -264,6 +264,8 @@ unsigned int bt_bap_stream_start(struct bt_bap_stream *stream,
 					bt_bap_stream_func_t func,
 					void *user_data);
 
+void bt_bap_stream_streaming(struct bt_bap_stream *stream);
+
 unsigned int bt_bap_stream_disable(struct bt_bap_stream *stream,
 					bool disable_links,
 					bt_bap_stream_func_t func,
-- 
2.34.1


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

* [PATCH 2/2] bap:Update transport acquire/release flow for bcast source
  2023-09-11  7:47 [PATCH 0/2] Update transport acquire/release flow for BAP bcast source Silviu Florian Barbulescu
  2023-09-11  7:47 ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Silviu Florian Barbulescu
@ 2023-09-11  7:47 ` Silviu Florian Barbulescu
  1 sibling, 0 replies; 5+ messages in thread
From: Silviu Florian Barbulescu @ 2023-09-11  7:47 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: claudia.rosu, mihai-octavian.urzica, silviu.barbulescu,
	vlad.pruteanu, andrei.istodorescu, iulia.tanasescu, luiz.dentz

Update transport acquire/release flow for BAP bcast source

---
 profiles/audio/bap.c       | 27 ++++++++++++-----
 profiles/audio/transport.c | 62 ++++++++++++++++++++++----------------
 2 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index ee90426b9..d21cfafc5 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -653,7 +653,12 @@ static void bap_io_close(struct bap_ep *ep)
 	DBG("ep %p", ep);
 
 	fd = g_io_channel_unix_get_fd(ep->io);
-	close(fd);
+	if (bt_bap_stream_get_type(ep->stream) ==
+				BT_BAP_STREAM_TYPE_BCAST) {
+		shutdown(fd, SHUT_RDWR);
+	} else {
+		close(fd);
+	}
 
 	g_io_channel_unref(ep->io);
 	ep->io = NULL;
@@ -1176,6 +1181,10 @@ static void iso_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	fd = g_io_channel_unix_get_fd(chan);
 
 	if (bt_bap_stream_set_io(stream, fd)) {
+		if (bt_bap_stream_get_type(stream) ==
+						BT_BAP_STREAM_TYPE_BCAST) {
+			bt_bap_stream_streaming(stream);
+		}
 		g_io_channel_set_close_on_unref(chan, FALSE);
 		return;
 	}
@@ -1712,6 +1721,12 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state,
 		} else
 			queue_remove(data->streams, stream);
 		break;
+	case BT_BAP_STREAM_STATE_RELEASING:
+		if (bt_bap_stream_get_type(stream) ==
+					BT_BAP_STREAM_TYPE_BCAST) {
+			bap_io_close(ep);
+		}
+		break;
 	case BT_BAP_STREAM_STATE_CONFIG:
 		if (ep && !ep->id) {
 			bap_create_io(data, ep, stream, true);
@@ -1735,18 +1750,16 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state,
 		}
 		break;
 	case BT_BAP_STREAM_STATE_QOS:
-		bap_create_io(data, ep, stream, true);
+		if (bt_bap_stream_get_type(stream) ==
+					BT_BAP_STREAM_TYPE_UCAST) {
+			bap_create_io(data, ep, stream, true);
+		}
 		break;
 	case BT_BAP_STREAM_STATE_ENABLING:
 		if (ep)
 			bap_create_io(data, ep, stream, false);
 		break;
 	case BT_BAP_STREAM_STATE_STREAMING:
-		if (bt_bap_stream_get_type(stream) ==
-				BT_BAP_STREAM_TYPE_BCAST) {
-			if (ep)
-				bap_create_io(data, ep, stream, false);
-		}
 		break;
 	}
 }
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index dd923b03e..6466e8291 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -606,11 +606,38 @@ static DBusMessage *try_acquire(DBusConnection *conn, DBusMessage *msg,
 	return NULL;
 }
 
+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 = owner->pending;
+	struct media_transport *transport = owner->transport;
+
+	/* Release always succeeds */
+	if (req) {
+		req->id = 0;
+		media_request_reply(req, 0);
+		media_owner_remove(owner);
+	}
+
+	transport_set_state(transport, TRANSPORT_STATE_IDLE);
+	media_transport_remove_owner(transport);
+}
+
+static void bap_disable_complete(struct bt_bap_stream *stream,
+					uint8_t code, uint8_t reason,
+					void *user_data)
+{
+	bap_stop_complete(stream, code, reason, user_data);
+}
+
 static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 					void *data)
 {
 	struct media_transport *transport = data;
 	struct media_owner *owner = transport->owner;
+	struct bap_transport *bap = transport->data;
 	const char *sender;
 	struct media_request *req;
 	guint id;
@@ -642,6 +669,11 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 	req = media_request_create(msg, id);
 	media_owner_add(owner, req);
 
+	if (bt_bap_stream_get_type(bap->stream) ==
+			BT_BAP_STREAM_TYPE_BCAST) {
+		bap_disable_complete(bap->stream, 0x00, 0x00, owner);
+		}
+
 	return NULL;
 }
 
@@ -1631,32 +1663,6 @@ static guint resume_bap(struct media_transport *transport,
 	return id;
 }
 
-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 = owner->pending;
-	struct media_transport *transport = owner->transport;
-
-	/* Release always succeeds */
-	if (req) {
-		req->id = 0;
-		media_request_reply(req, 0);
-		media_owner_remove(owner);
-	}
-
-	transport_set_state(transport, TRANSPORT_STATE_IDLE);
-	media_transport_remove_owner(transport);
-}
-
-static void bap_disable_complete(struct bt_bap_stream *stream,
-					uint8_t code, uint8_t reason,
-					void *user_data)
-{
-	bap_stop_complete(stream, code, reason, user_data);
-}
-
 static guint suspend_bap(struct media_transport *transport,
 				struct media_owner *owner)
 {
@@ -1763,6 +1769,10 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
 		if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
 			bap_update_bcast_qos(transport);
 		break;
+	case BT_BAP_STREAM_STATE_RELEASING:
+		if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
+			return;
+		break;
 	}
 
 	io = bt_bap_stream_get_io(stream);
-- 
2.34.1


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

* RE: Update transport acquire/release flow for BAP bcast source
  2023-09-11  7:47 ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Silviu Florian Barbulescu
@ 2023-09-11  9:26   ` bluez.test.bot
  2023-09-12 18:44   ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Luiz Augusto von Dentz
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2023-09-11  9:26 UTC (permalink / raw)
  To: linux-bluetooth, silviu.barbulescu

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=782830

---Test result---

Test Summary:
CheckPatch                    PASS      1.00 seconds
GitLint                       PASS      0.58 seconds
BuildEll                      PASS      27.23 seconds
BluezMake                     PASS      810.49 seconds
MakeCheck                     PASS      11.90 seconds
MakeDistcheck                 PASS      159.21 seconds
CheckValgrind                 PASS      254.71 seconds
CheckSmatch                   PASS      346.27 seconds
bluezmakeextell               PASS      104.10 seconds
IncrementalBuild              PASS      1346.24 seconds
ScanBuild                     PASS      1040.07 seconds



---
Regards,
Linux Bluetooth


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

* Re: [PATCH 1/2] shared/bap:Update stream enable/disable flow bcast source
  2023-09-11  7:47 ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Silviu Florian Barbulescu
  2023-09-11  9:26   ` Update transport acquire/release flow for BAP " bluez.test.bot
@ 2023-09-12 18:44   ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-09-12 18:44 UTC (permalink / raw)
  To: Silviu Florian Barbulescu
  Cc: linux-bluetooth, claudia.rosu, mihai-octavian.urzica,
	vlad.pruteanu, andrei.istodorescu, iulia.tanasescu

Hi Silviu,

On Mon, Sep 11, 2023 at 12:47 AM Silviu Florian Barbulescu
<silviu.barbulescu@nxp.com> wrote:
>
> Update stream enable/disable flow for BAP broadcast source
>
> ---
>  src/shared/bap.c | 51 +++++++++++++++++++++++++++++++++++-------------
>  src/shared/bap.h |  2 ++
>  2 files changed, 39 insertions(+), 14 deletions(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index 1c43680c2..801716dd9 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -1331,6 +1331,11 @@ static void stream_set_state_broadcast(struct bt_bap_stream *stream,
>         ep->old_state = ep->state;
>         ep->state = state;
>
> +       DBG(bap, "stream %p dir 0x%02x: %s -> %s", stream,
> +                       bt_bap_stream_get_dir(stream),
> +                       bt_bap_stream_statestr(stream->ep->old_state),
> +                       bt_bap_stream_statestr(stream->ep->state));
> +
>         bt_bap_ref(bap);
>
>         for (entry = queue_get_entries(bap->state_cbs); entry;
> @@ -1492,7 +1497,7 @@ static void ep_config_cb(struct bt_bap_stream *stream, int err)
>                 return;
>
>         if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) {
> -               stream_set_state_broadcast(stream, BT_BAP_STREAM_STATE_CONFIG);
> +               stream_set_state_broadcast(stream, BT_BAP_STREAM_STATE_QOS);
>                 return;
>         }
>
> @@ -4698,13 +4703,19 @@ unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream,
>                 break;
>         case BT_BAP_STREAM_TYPE_BCAST:
>                 stream_set_state_broadcast(stream,
> -                                       BT_BAP_STREAM_STATE_STREAMING);
> +                                       BT_BAP_STREAM_STATE_CONFIG);
>                 return 1;
>         }
>
>         return ret;
>  }
>
> +void bt_bap_stream_streaming(struct bt_bap_stream *stream)
> +{
> +               stream_set_state_broadcast(stream,
> +                                       BT_BAP_STREAM_STATE_STREAMING);
> +}
> +
>  unsigned int bt_bap_stream_start(struct bt_bap_stream *stream,
>                                         bt_bap_stream_func_t func,
>                                         void *user_data)
> @@ -4779,24 +4790,36 @@ unsigned int bt_bap_stream_disable(struct bt_bap_stream *stream,
>                 return 0;
>         }
>
> -       memset(&disable, 0, sizeof(disable));
> +       switch (bt_bap_stream_get_type(stream)) {
> +       case BT_BAP_STREAM_TYPE_UCAST:
> +               memset(&disable, 0, sizeof(disable));
>
> -       disable.ase = stream->ep->id;
> +               disable.ase = stream->ep->id;
>
> -       iov.iov_base = &disable;
> -       iov.iov_len = sizeof(disable);
> +               iov.iov_base = &disable;
> +               iov.iov_len = sizeof(disable);
>
> -       req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func, user_data);
> +               req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func,
> +                                                       user_data);
>
> -       if (!bap_queue_req(stream->bap, req)) {
> -               bap_req_free(req);
> -               return 0;
> -       }
> +               if (!bap_queue_req(stream->bap, req)) {
> +                       bap_req_free(req);
> +                       return 0;
> +               }
>
> -       if (disable_links)
> -               queue_foreach(stream->links, bap_stream_disable_link, NULL);
> +               if (disable_links)
> +                       queue_foreach(stream->links, bap_stream_disable_link,
> +                                                       NULL);
>
> -       return req->id;
> +               return req->id;
> +
> +       case BT_BAP_STREAM_TYPE_BCAST:
> +               stream_set_state_broadcast(stream,
> +                                       BT_BAP_STREAM_STATE_RELEASING);
> +               return 1;
> +       }
> +
> +       return 0;
>  }
>
>  unsigned int bt_bap_stream_stop(struct bt_bap_stream *stream,
> diff --git a/src/shared/bap.h b/src/shared/bap.h
> index edb5c1bed..d3c9b241e 100644
> --- a/src/shared/bap.h
> +++ b/src/shared/bap.h
> @@ -264,6 +264,8 @@ unsigned int bt_bap_stream_start(struct bt_bap_stream *stream,
>                                         bt_bap_stream_func_t func,
>                                         void *user_data);
>
> +void bt_bap_stream_streaming(struct bt_bap_stream *stream);
> +

Lets use bt_bap_stream_start and handle this internally instead of
introducing new APIs specific to broadcast.

>  unsigned int bt_bap_stream_disable(struct bt_bap_stream *stream,
>                                         bool disable_links,
>                                         bt_bap_stream_func_t func,
> --
> 2.34.1
>


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2023-09-12 18:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11  7:47 [PATCH 0/2] Update transport acquire/release flow for BAP bcast source Silviu Florian Barbulescu
2023-09-11  7:47 ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Silviu Florian Barbulescu
2023-09-11  9:26   ` Update transport acquire/release flow for BAP " bluez.test.bot
2023-09-12 18:44   ` [PATCH 1/2] shared/bap:Update stream enable/disable flow " Luiz Augusto von Dentz
2023-09-11  7:47 ` [PATCH 2/2] bap:Update transport acquire/release flow for " Silviu Florian Barbulescu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).