diff mbox series

[1/2] shared/bap:Update stream enable/disable flow bcast source

Message ID 20230911074711.62493-2-silviu.barbulescu@nxp.com
State New
Headers show
Series Update transport acquire/release flow for BAP bcast source | expand

Commit Message

Silviu Florian Barbulescu Sept. 11, 2023, 7:47 a.m. UTC
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(-)

Comments

bluez.test.bot@gmail.com Sept. 11, 2023, 9:26 a.m. UTC | #1
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
Luiz Augusto von Dentz Sept. 12, 2023, 6:44 p.m. UTC | #2
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
>
diff mbox series

Patch

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,