shared/bap: Pass bcode as a reference instead of value
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 19 Jun 2023 20:30:32 +0000 (13:30 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 13:34:03 +0000 (19:04 +0530)
This makes bcode field a pointer which makes it simpler to detect when
it is set and also fixes the usage of util_iov_free which expects it to
be allocated.

profiles/audio/bap.c
src/shared/bap.h

index 377e4b3eaf1ce005ab46b8ac4025d7a3844f34e7..4ce8efe30345640c68c010540ab4e4bc8431ba53 100644 (file)
@@ -429,12 +429,9 @@ static int parse_properties(DBusMessageIter *props, struct iovec **caps,
                        dbus_message_iter_get_basic(&value,
                                                        &qos->bcast.timeout);
                } else if (!strcasecmp(key, "BroadcastCode")) {
-                       struct iovec *iov;
-
                        if (var != DBUS_TYPE_ARRAY)
                                goto fail;
-                       iov = &qos->bcast.bcode;
-                       parse_array(&value, &iov);
+                       parse_array(&value, &qos->bcast.bcode);
                }
 
                dbus_message_iter_next(props);
@@ -626,7 +623,7 @@ static void ep_free(void *data)
        util_iov_free(ep->caps, 1);
        util_iov_free(ep->metadata, 1);
        if (bt_bap_stream_get_type(ep->stream) == BT_BAP_STREAM_TYPE_BCAST)
-               util_iov_free(&ep->qos.bcast.bcode, 1);
+               util_iov_free(ep->qos.bcast.bcode, 1);
        free(ep->path);
        free(ep);
 }
@@ -1270,7 +1267,8 @@ static void bap_create_bcast_io(struct bap_data *data, struct bap_ep *ep,
        iso_qos.bcast.packing = ep->qos.bcast.packing;
        iso_qos.bcast.framing = ep->qos.bcast.framing;
        iso_qos.bcast.encryption = ep->qos.bcast.encryption;
-       memcpy(iso_qos.bcast.bcode, ep->qos.bcast.bcode.iov_base, 16);
+       if (ep->qos.bcast.bcode)
+               memcpy(iso_qos.bcast.bcode, ep->qos.bcast.bcode->iov_base, 16);
        iso_qos.bcast.options = ep->qos.bcast.options;
        iso_qos.bcast.skip = ep->qos.bcast.skip;
        iso_qos.bcast.sync_timeout = ep->qos.bcast.sync_timeout;
@@ -1813,7 +1811,7 @@ static struct btd_profile bap_profile = {
        .disconnect     = bap_disconnect,
        .adapter_probe  = bap_adapter_probe,
        .adapter_remove = bap_adapter_remove,
-       .auto_connect   = true,
+       .auto_connect   = false,
        .experimental   = true,
 };
 
index 8fc41864a77e04b3d171ba8915aa7029f3397fd1..50b567663c32f4ad3dda030c8e59005316f6861f 100644 (file)
@@ -79,7 +79,7 @@ struct bt_bap_bcast_qos {
        uint8_t  packing;
        uint8_t  framing;
        uint8_t  encryption;
-       struct iovec bcode;
+       struct iovec *bcode;
        uint8_t  options;
        uint16_t skip;
        uint16_t sync_timeout;