media: Fix custom property registration for multiple adapters
Luiz Augusto von Dentz
maintainerPATCH 1/1 media: Fix custom property registration for multiple adapters
From: Luiz Augusto von Dentz <[email protected]>
The function btd_profile_add_custom_prop register a custom property for an UUID which is valid for every adapter so its user_data cannot be tied to a single adapter.
To fix this now NULL is passed as user_data and the callbacks checks if the adapter passed has been registered and if there is an endpoint for the UUID requested.
--- profiles/audio/media.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
profiles/audio/media.c +23 -4
@@ -607,13 +607,28 @@ static gboolean endpoint_init_a2dp_sink(struct media_endpoint *endpoint,return TRUE; } +static struct media_adapter *find_adapter (struct btd_device *device) +{ +GSList *l; + +for (l = adapters; l; l = l->next) { +struct media_adapter *adapter = l->data; + +if (adapter->btd_adapter ==device_get_adapter (device)) +return adapter; + } + +return NULL ; +} +static bool endpoint_properties_exists (const char *uuid,struct btd_device *dev,void *user_data) { -struct media_adapter *adapter = user_data; +struct media_adapter *adapter; -if (adapter->btd_adapter !=device_get_adapter (dev)) + adapter =find_adapter (dev); +if (adapter ==NULL )return false;if (media_adapter_find_endpoint (adapter,NULL ,NULL , uuid) ==NULL )
@@ -659,10 +674,14 @@ static bool endpoint_properties_get(const char *uuid,DBusMessageIter *iter, void *user_data) { - struct media_adapter *adapter = user_data; + struct media_adapter *adapter;DBusMessageIter dict;GSList *l; + adapter =find_adapter (dev); +if (adapter ==NULL ) +return false; + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING
@@ -743,7 +762,7 @@ static struct media_endpoint *media_endpoint_create(struct media_adapter *adaptebtd_profile_add_custom_prop (uuid,"a{sv}" ,"MediaEndpoints" , endpoint_properties_exists, endpoint_properties_get, - adapter); +NULL ); } adapter->endpoints =g_slist_append (adapter->endpoints, endpoint);
Signature · 1 line
1.8.0.2
Johan Hedberg
AppliedHi Luiz,
Quoted 10 lines · Luiz Augusto von Dentz
The function
btd_profile_add_custom_propregister a custom property for an UUID which is valid for every adapter so itsuser_datacannot be tied to a single adapter.To fix this now NULL is passed as
user_dataand the callbacks checks if the adapter passed has been registered and if there is an endpoint for the UUID requested.--- profiles/audio/media.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
Applied. Thanks.
Johan