mbox series

[BlueZ,0/1] bap: Fix bcast endpoint config

Message ID 20240119150443.3163-1-iulia.tanasescu@nxp.com
Headers show
Series bap: Fix bcast endpoint config | expand

Message

Iulia Tanasescu Jan. 19, 2024, 3:04 p.m. UTC
This updates the way broadcast is differentiated from unicast
at endpoint configuration: Instead of checking if setup->base
is allocated, check lpac type.

This fixes the transport acquire crash currently visible for
broadcast source.

Iulia Tanasescu (1):
  bap: Fix bcast endpoint config

 profiles/audio/bap.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)


base-commit: e108c744fa8dfa1c4f54257532f3433a47179869

Comments

Luiz Augusto von Dentz Jan. 19, 2024, 3:11 p.m. UTC | #1
Hi Iulia,

On Fri, Jan 19, 2024 at 10:04 AM Iulia Tanasescu
<iulia.tanasescu@nxp.com> wrote:
>
> This updates the way broadcast is differentiated from unicast
> at endpoint configuration: Instead of checking if setup->base
> is allocated, check lpac type.
>
> ---
>  profiles/audio/bap.c | 39 ++++++++++++++++++---------------------
>  1 file changed, 18 insertions(+), 21 deletions(-)
>
> diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
> index b88876485..137ed7d39 100644
> --- a/profiles/audio/bap.c
> +++ b/profiles/audio/bap.c
> @@ -4,7 +4,7 @@
>   *  BlueZ - Bluetooth protocol stack for Linux
>   *
>   *  Copyright (C) 2022  Intel Corporation. All rights reserved.
> - *  Copyright 2023 NXP
> + *  Copyright 2023-2024 NXP
>   *
>   *
>   */
> @@ -617,15 +617,16 @@ static int parse_bcast_qos(const char *key, int var, DBusMessageIter *iter,
>         return 0;
>  }
>
> -static int parse_qos(DBusMessageIter *iter, struct bt_bap_qos *qos,
> -                       struct iovec **base)
> +static int parse_qos(DBusMessageIter *iter, uint8_t pac_type,
> +                               struct bt_bap_qos *qos)
>  {
>         DBusMessageIter array;
>         const char *key;
>         int (*parser)(const char *key, int var, DBusMessageIter *iter,
>                         struct bt_bap_qos *qos);
>
> -       if (*base)
> +       if ((pac_type == BT_BAP_BCAST_SOURCE) ||
> +               (pac_type == BT_BAP_BCAST_SINK))
>                 parser = parse_bcast_qos;
>         else
>                 parser = parse_ucast_qos;
> @@ -656,9 +657,9 @@ static int parse_qos(DBusMessageIter *iter, struct bt_bap_qos *qos,
>         return 0;
>  }
>
> -static int parse_configuration(DBusMessageIter *props, struct iovec **caps,
> -                               struct iovec **metadata, struct iovec **base,
> -                               struct bt_bap_qos *qos)
> +static int parse_configuration(DBusMessageIter *props, uint8_t pac_type,
> +                               struct iovec **caps, struct iovec **metadata,
> +                               struct iovec **base, struct bt_bap_qos *qos)
>  {
>         const char *key;
>         struct iovec iov;
> @@ -686,6 +687,12 @@ static int parse_configuration(DBusMessageIter *props, struct iovec **caps,
>
>                         util_iov_free(*caps, 1);
>                         *caps = util_iov_dup(&iov, 1);
> +
> +                       /* Currently, the base iovec only duplicates
> +                        * setup->caps. TODO: Dynamically generate
> +                        * base using received caps.
> +                        */
> +                       *base = util_iov_dup(*caps, 1);
>                 } else if (!strcasecmp(key, "Metadata")) {
>                         if (var != DBUS_TYPE_ARRAY)
>                                 goto fail;
> @@ -699,24 +706,13 @@ static int parse_configuration(DBusMessageIter *props, struct iovec **caps,
>                         if (var != DBUS_TYPE_ARRAY)
>                                 goto fail;
>
> -                       if (parse_qos(&value, qos, base))
> +                       if (parse_qos(&value, pac_type, qos))
>                                 goto fail;
>                 }
>
>                 dbus_message_iter_next(props);
>         }
>
> -       if (*base) {
> -               uint32_t presDelay;
> -               uint8_t numSubgroups, numBis;
> -               struct bt_bap_codec codec;
> -
> -               util_iov_memcpy(*base, (*caps)->iov_base, (*caps)->iov_len);
> -               parse_base((*caps)->iov_base, (*caps)->iov_len, bap_debug,
> -                       &presDelay, &numSubgroups, &numBis, &codec,
> -                       caps, NULL);
> -       }
> -
>         return 0;
>
>  fail:
> @@ -882,8 +878,9 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg,
>                 setup->qos.ucast.cis_id = BT_ISO_QOS_CIS_UNSET;
>         }
>
> -       if (parse_configuration(&props, &setup->caps, &setup->metadata,
> -                               &setup->base, &setup->qos) < 0) {
> +       if (parse_configuration(&props, bt_bap_pac_get_type(ep->lpac),
> +                               &setup->caps, &setup->metadata, &setup->base,
> +                               &setup->qos) < 0) {
>                 DBG("Unable to parse configuration");
>                 setup_free(setup);
>                 return btd_error_invalid_args(msg);
> --
> 2.39.2

I sort of did the same thing but end up refactoring the code in the process:

https://patchwork.kernel.org/project/bluetooth/list/?series=817943

So it's worth checking if I didn't break it further.