diff mbox series

[BlueZ,v3,4/7] shared/bap: Add state in stream struct for bcast source

Message ID 20240215212356.310301-5-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. 15, 2024, 9:23 p.m. UTC
Add state support in the stream struct for broadcast source.
---
 src/shared/bap.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

Comments

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

On Thu, Feb 15, 2024 at 4:24 PM Silviu Florian Barbulescu
<silviu.barbulescu@nxp.com> wrote:
>
> Add state support in the stream struct for broadcast source.
> ---
>  src/shared/bap.c | 32 ++++++++++++++++++--------------
>  1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index a39b95407..524bfa058 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -251,6 +251,8 @@ struct bt_bap_stream {
>         struct bt_bap_stream *link;
>         struct bt_bap_stream_io *io;
>         const struct bt_bap_stream_ops *ops;
> +       uint8_t bcast_old_state;
> +       uint8_t bcast_state;

Lets have it as generic one, old_state and state.

>         bool client;
>         void *user_data;
>  };
> @@ -1271,7 +1273,6 @@ static void bap_stream_state_changed(struct bt_bap_stream *stream)
>
>  static void stream_set_state(struct bt_bap_stream *stream, uint8_t state)
>  {
> -       struct bt_bap_endpoint *ep = stream->ep;
>         struct bt_bap *bap = stream->bap;
>
>         /* Check if ref_count is already 0 which means detaching is in
> @@ -1283,14 +1284,6 @@ static void stream_set_state(struct bt_bap_stream *stream, uint8_t state)
>                 return;
>         }
>
> -       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));
> -
>         if (stream->ops && stream->ops->set_state)
>                 stream->ops->set_state(stream, state);
>
> @@ -1527,6 +1520,14 @@ static void bap_ucast_set_state(struct bt_bap_stream *stream, uint8_t state)
>  {
>         struct bt_bap_endpoint *ep = stream->ep;
>
> +       ep->old_state = ep->state;
> +       ep->state = state;
> +
> +       DBG(stream->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));
> +
>         if (stream->lpac->type == BT_BAP_BCAST_SINK || stream->client)
>                 goto done;
>
> @@ -1942,22 +1943,25 @@ static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state)
>         struct bt_bap *bap = stream->bap;
>         const struct queue_entry *entry;
>
> +       stream->bcast_old_state = stream->bcast_state;
> +       stream->bcast_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_stream_statestr(stream->bcast_old_state),
> +                       bt_bap_stream_statestr(stream->bcast_state));
>
>         for (entry = queue_get_entries(bap->state_cbs); entry;
>                                                         entry = entry->next) {
>                 struct bt_bap_state *state = entry->data;
>
>                 if (state->func)
> -                       state->func(stream, stream->ep->old_state,
> -                                       stream->ep->state, state->data);
> +                       state->func(stream, stream->bcast_old_state,
> +                                       stream->bcast_state, state->data);
>         }
>
>         /* Post notification updates */
> -       switch (stream->ep->state) {
> +       switch (stream->bcast_state) {
>         case BT_ASCS_ASE_STATE_IDLE:
>                 bap_stream_detach(stream);
>                 break;
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index a39b95407..524bfa058 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -251,6 +251,8 @@  struct bt_bap_stream {
 	struct bt_bap_stream *link;
 	struct bt_bap_stream_io *io;
 	const struct bt_bap_stream_ops *ops;
+	uint8_t bcast_old_state;
+	uint8_t bcast_state;
 	bool client;
 	void *user_data;
 };
@@ -1271,7 +1273,6 @@  static void bap_stream_state_changed(struct bt_bap_stream *stream)
 
 static void stream_set_state(struct bt_bap_stream *stream, uint8_t state)
 {
-	struct bt_bap_endpoint *ep = stream->ep;
 	struct bt_bap *bap = stream->bap;
 
 	/* Check if ref_count is already 0 which means detaching is in
@@ -1283,14 +1284,6 @@  static void stream_set_state(struct bt_bap_stream *stream, uint8_t state)
 		return;
 	}
 
-	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));
-
 	if (stream->ops && stream->ops->set_state)
 		stream->ops->set_state(stream, state);
 
@@ -1527,6 +1520,14 @@  static void bap_ucast_set_state(struct bt_bap_stream *stream, uint8_t state)
 {
 	struct bt_bap_endpoint *ep = stream->ep;
 
+	ep->old_state = ep->state;
+	ep->state = state;
+
+	DBG(stream->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));
+
 	if (stream->lpac->type == BT_BAP_BCAST_SINK || stream->client)
 		goto done;
 
@@ -1942,22 +1943,25 @@  static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state)
 	struct bt_bap *bap = stream->bap;
 	const struct queue_entry *entry;
 
+	stream->bcast_old_state = stream->bcast_state;
+	stream->bcast_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_stream_statestr(stream->bcast_old_state),
+			bt_bap_stream_statestr(stream->bcast_state));
 
 	for (entry = queue_get_entries(bap->state_cbs); entry;
 							entry = entry->next) {
 		struct bt_bap_state *state = entry->data;
 
 		if (state->func)
-			state->func(stream, stream->ep->old_state,
-					stream->ep->state, state->data);
+			state->func(stream, stream->bcast_old_state,
+					stream->bcast_state, state->data);
 	}
 
 	/* Post notification updates */
-	switch (stream->ep->state) {
+	switch (stream->bcast_state) {
 	case BT_ASCS_ASE_STATE_IDLE:
 		bap_stream_detach(stream);
 		break;