* [PATCH BlueZ] media: Fix custom property registration for multiple adapters
@ 2013-01-21 13:34 Luiz Augusto von Dentz
2013-01-28 0:03 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2013-01-21 13:34 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
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(-)
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 15dab8c..0ae9932 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -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 *adapte
btd_profile_add_custom_prop(uuid, "a{sv}", "MediaEndpoints",
endpoint_properties_exists,
endpoint_properties_get,
- adapter);
+ NULL);
}
adapter->endpoints = g_slist_append(adapter->endpoints, endpoint);
--
1.8.0.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH BlueZ] media: Fix custom property registration for multiple adapters
2013-01-21 13:34 [PATCH BlueZ] media: Fix custom property registration for multiple adapters Luiz Augusto von Dentz
@ 2013-01-28 0:03 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2013-01-28 0:03 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Mon, Jan 21, 2013, Luiz Augusto von Dentz wrote:
> 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(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-28 0:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-21 13:34 [PATCH BlueZ] media: Fix custom property registration for multiple adapters Luiz Augusto von Dentz
2013-01-28 0:03 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).