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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Silviu,

On Thu, Feb 15, 2024 at 4:24 PM Silviu Florian Barbulescu
<silviu.barbulescu@xxxxxxx> 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
>


-- 
Luiz Augusto von Dentz





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux