diff mbox series

[BlueZ,v2,2/7] shared/bap: Create multiple streams for the same pac

Message ID 20240212153222.8191-3-silviu.barbulescu@nxp.com (mailing list archive)
State Superseded
Headers show
Series Add support for multiple BISes on the bcast source | expand

Checks

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

Commit Message

Silviu Florian Barbulescu Feb. 12, 2024, 3:32 p.m. UTC
Broadcast source requires to create multiple streams for one pac.
This is required for multiple BISes support.
---
 src/shared/bap.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

Comments

Luiz Augusto von Dentz Feb. 12, 2024, 10:17 p.m. UTC | #1
Hi Silviu,

On Mon, Feb 12, 2024 at 10:32 AM Silviu Florian Barbulescu
<silviu.barbulescu@nxp.com> wrote:
>
> Broadcast source requires to create multiple streams for one pac.
> This is required for multiple BISes support.
> ---
>  src/shared/bap.c | 28 ++++++++++++++++++++++++----
>  1 file changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index e26dbf944..f0ffdebfe 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -5156,7 +5156,7 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
>                                         struct iovec *data)
>  {
>         struct bt_bap_stream *stream;
> -       struct bt_bap_endpoint *ep;
> +       struct bt_bap_endpoint *ep = NULL;
>         struct match_pac match;
>
>         if (!bap)
> @@ -5212,12 +5212,32 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
>         match.lpac = lpac;
>         match.rpac = rpac;
>
> -       /* Check for existing stream */
> -       ep = queue_find(bap->remote_eps, find_ep_pacs, &match);
> +       /* Broadcast source supports multiple endpoints (multiple BISes)
> +        * for one pac so allow it to register a new endpoint even if
> +        * others already exist.
> +        */
> +       if (lpac->type != BT_BAP_BCAST_SOURCE) {
> +               /* Check for existing stream */
> +               ep = queue_find(bap->remote_eps, find_ep_pacs, &match);
> +       }
> +
>         if (!ep) {
>                 /* Check for unused ASE */
>                 ep = queue_find(bap->remote_eps, find_ep_unused, &match);
> -               if (!ep) {
> +               if (!ep && lpac->type == BT_BAP_BCAST_SOURCE) {
> +                       /* Push a new remote endpoint with direction
> +                        * broadcast source
> +                        */
> +                       ep = bap_endpoint_new_broadcast(bap->rdb,
> +                                       BT_BAP_BCAST_SOURCE);
> +
> +                       if (ep)
> +                               queue_push_tail(bap->remote_eps, ep);
> +                       else {
> +                               DBG(bap, "Unable to create endpoint");
> +                               return NULL;
> +                       }
> +               } else if (!ep) {

Perhaps we need a dedicated callback from creating streams to avoid
having to add such checks everywhere, that said I don't quite
understand why we have Broadcast Source to find a remote endpoint, it
shall use a local one instead and perhaps have the ep struct support
multiple streams to be attached so we don't have to create dummy
endpoints just to be able to create new streams.

>                         DBG(bap, "Unable to find unused ASE");
>                         return NULL;
>                 }
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index e26dbf944..f0ffdebfe 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -5156,7 +5156,7 @@  struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
 					struct iovec *data)
 {
 	struct bt_bap_stream *stream;
-	struct bt_bap_endpoint *ep;
+	struct bt_bap_endpoint *ep = NULL;
 	struct match_pac match;
 
 	if (!bap)
@@ -5212,12 +5212,32 @@  struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
 	match.lpac = lpac;
 	match.rpac = rpac;
 
-	/* Check for existing stream */
-	ep = queue_find(bap->remote_eps, find_ep_pacs, &match);
+	/* Broadcast source supports multiple endpoints (multiple BISes)
+	 * for one pac so allow it to register a new endpoint even if
+	 * others already exist.
+	 */
+	if (lpac->type != BT_BAP_BCAST_SOURCE) {
+		/* Check for existing stream */
+		ep = queue_find(bap->remote_eps, find_ep_pacs, &match);
+	}
+
 	if (!ep) {
 		/* Check for unused ASE */
 		ep = queue_find(bap->remote_eps, find_ep_unused, &match);
-		if (!ep) {
+		if (!ep && lpac->type == BT_BAP_BCAST_SOURCE) {
+			/* Push a new remote endpoint with direction
+			 * broadcast source
+			 */
+			ep = bap_endpoint_new_broadcast(bap->rdb,
+					BT_BAP_BCAST_SOURCE);
+
+			if (ep)
+				queue_push_tail(bap->remote_eps, ep);
+			else {
+				DBG(bap, "Unable to create endpoint");
+				return NULL;
+			}
+		} else if (!ep) {
 			DBG(bap, "Unable to find unused ASE");
 			return NULL;
 		}