diff mbox series

[BlueZ,v4,4/4] bap: Update properties of endpoints

Message ID 20240411200305.183703-4-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit 9be5d8018dd1b75cb9cf9d206b389049a0515c74
Headers show
Series [BlueZ,v4,1/4] shared/bap: Fix not updating location | 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

Luiz Augusto von Dentz April 11, 2024, 8:03 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If a MediaEndpoint if found during registration stage attempt to check
and update properties since they may have been updated at later stage
when a session has been attached.
---
 profiles/audio/bap.c | 48 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index db0af7e7cba5..30049f0fb3a7 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -92,6 +92,9 @@  struct bap_ep {
 	struct bap_data *data;
 	struct bt_bap_pac *lpac;
 	struct bt_bap_pac *rpac;
+	uint32_t locations;
+	uint16_t supported_context;
+	uint16_t context;
 	struct queue *setups;
 };
 
@@ -376,9 +379,10 @@  static gboolean get_locations(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
 	struct bap_ep *ep = data;
-	uint32_t locations = bt_bap_pac_get_locations(ep->rpac);
 
-	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &locations);
+	ep->locations = bt_bap_pac_get_locations(ep->rpac);
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &ep->locations);
 
 	return TRUE;
 }
@@ -387,9 +391,11 @@  static gboolean get_supported_context(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
 	struct bap_ep *ep = data;
-	uint16_t context = bt_bap_pac_get_supported_context(ep->rpac);
 
-	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &context);
+	ep->supported_context = bt_bap_pac_get_supported_context(ep->rpac);
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16,
+					&ep->supported_context);
 
 	return TRUE;
 }
@@ -398,9 +404,10 @@  static gboolean get_context(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
 	struct bap_ep *ep = data;
-	uint16_t context = bt_bap_pac_get_context(ep->rpac);
 
-	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &context);
+	ep->context = bt_bap_pac_get_context(ep->rpac);
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &ep->context);
 
 	return TRUE;
 }
@@ -1261,6 +1268,31 @@  static struct bap_ep *ep_register_bcast(struct bap_data *data,
 	return ep;
 }
 
+static void ep_update_properties(struct bap_ep *ep)
+{
+	if (!ep->rpac)
+		return;
+
+	if (ep->locations != bt_bap_pac_get_locations(ep->rpac))
+		g_dbus_emit_property_changed(btd_get_dbus_connection(),
+						ep->path,
+						MEDIA_ENDPOINT_INTERFACE,
+						"Locations");
+
+	if (ep->supported_context !=
+				bt_bap_pac_get_supported_context(ep->rpac))
+		g_dbus_emit_property_changed(btd_get_dbus_connection(),
+						ep->path,
+						MEDIA_ENDPOINT_INTERFACE,
+						"SupportedContext");
+
+	if (ep->context != bt_bap_pac_get_context(ep->rpac))
+		g_dbus_emit_property_changed(btd_get_dbus_connection(),
+						ep->path,
+						MEDIA_ENDPOINT_INTERFACE,
+						"Context");
+}
+
 static struct bap_ep *ep_register(struct btd_service *service,
 					struct bt_bap_pac *lpac,
 					struct bt_bap_pac *rpac)
@@ -1289,8 +1321,10 @@  static struct bap_ep *ep_register(struct btd_service *service,
 	}
 
 	ep = queue_find(queue, match_ep, &match);
-	if (ep)
+	if (ep) {
+		ep_update_properties(ep);
 		return ep;
+	}
 
 	ep = new0(struct bap_ep, 1);
 	ep->data = data;