diff mbox series

[BlueZ,v4,2/5] transport: Add support to update the transport config

Message ID 20240318163853.68598-3-silviu.barbulescu@nxp.com (mailing list archive)
State New, archived
Headers show
Series Broadcast source reconfiguration support | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS

Commit Message

Silviu Florian Barbulescu March 18, 2024, 4:38 p.m. UTC
Add support to update the transport configuration

---
 profiles/audio/transport.c | 21 +++++++++++++++++++++
 profiles/audio/transport.h |  1 +
 2 files changed, 22 insertions(+)

Comments

Luiz Augusto von Dentz March 18, 2024, 5:23 p.m. UTC | #1
Hi Silviu,

On Mon, Mar 18, 2024 at 4:39 PM Silviu Florian Barbulescu
<silviu.barbulescu@nxp.com> wrote:
>
> Add support to update the transport configuration
>
> ---
>  profiles/audio/transport.c | 21 +++++++++++++++++++++
>  profiles/audio/transport.h |  1 +
>  2 files changed, 22 insertions(+)
>
> diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
> index 159fbd575..122c3339e 100644
> --- a/profiles/audio/transport.c
> +++ b/profiles/audio/transport.c
> @@ -1483,6 +1483,27 @@ static void bap_update_bcast_qos(const struct media_transport *transport)
>                         "Configuration");
>  }
>
> +void bap_update_bcast_config(struct media_transport *transport)
> +{
> +       struct bap_transport *bap = transport->data;
> +       struct iovec *cc;
> +
> +       cc = bt_bap_stream_get_config(bap->stream);
> +
> +       if (((int)cc->iov_len != transport->size) ||
> +               (memcmp(cc->iov_base, transport->configuration,
> +                       transport->size) != 0)) {

Lets just use util_iov_memcmp, just init transport->configuration into an iov.

> +               free(transport->configuration);
> +               transport->configuration = util_memdup(cc->iov_base,
> +                                                       cc->iov_len);
> +               transport->size = cc->iov_len;
> +
> +               g_dbus_emit_property_changed(btd_get_dbus_connection(),
> +                       transport->path, MEDIA_TRANSPORT_INTERFACE,
> +                       "Configuration");
> +       }
> +}
> +
>  static guint transport_bap_resume(struct media_transport *transport,
>                                 struct media_owner *owner)
>  {
> diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h
> index b46bc8025..6df419a67 100644
> --- a/profiles/audio/transport.h
> +++ b/profiles/audio/transport.h
> @@ -16,6 +16,7 @@ struct media_transport *media_transport_create(struct btd_device *device,
>                                                 uint8_t *configuration,
>                                                 size_t size, void *data,
>                                                 void *stream);
> +void bap_update_bcast_config(struct media_transport *transport);
>
>  void media_transport_destroy(struct media_transport *transport);
>  const char *media_transport_get_path(struct media_transport *transport);
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 159fbd575..122c3339e 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -1483,6 +1483,27 @@  static void bap_update_bcast_qos(const struct media_transport *transport)
 			"Configuration");
 }
 
+void bap_update_bcast_config(struct media_transport *transport)
+{
+	struct bap_transport *bap = transport->data;
+	struct iovec *cc;
+
+	cc = bt_bap_stream_get_config(bap->stream);
+
+	if (((int)cc->iov_len != transport->size) ||
+		(memcmp(cc->iov_base, transport->configuration,
+			transport->size) != 0)) {
+		free(transport->configuration);
+		transport->configuration = util_memdup(cc->iov_base,
+							cc->iov_len);
+		transport->size = cc->iov_len;
+
+		g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			transport->path, MEDIA_TRANSPORT_INTERFACE,
+			"Configuration");
+	}
+}
+
 static guint transport_bap_resume(struct media_transport *transport,
 				struct media_owner *owner)
 {
diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h
index b46bc8025..6df419a67 100644
--- a/profiles/audio/transport.h
+++ b/profiles/audio/transport.h
@@ -16,6 +16,7 @@  struct media_transport *media_transport_create(struct btd_device *device,
 						uint8_t *configuration,
 						size_t size, void *data,
 						void *stream);
+void bap_update_bcast_config(struct media_transport *transport);
 
 void media_transport_destroy(struct media_transport *transport);
 const char *media_transport_get_path(struct media_transport *transport);