[RFC v1 09/14] bluetooth: Parse media transport's properties

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

Consider the media transport when a PropertiesChanged signal is
received.

Note that the transport might have an owner other than BlueZ, and thus
the property changes would be emitted from arbitrary senders. For
performance reasons, the installed match considers the interface name
where the property has changed.

It could be possible to install and remove the D-Bus matches dynamically
when a new owner is registered/unregistered, but filtering based on the
interface name seems good enough already.
---
 src/modules/bluetooth/bluetooth-util.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 9988075..c4235d5 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1082,6 +1082,25 @@ static int transport_parse_property(pa_bluetooth_transport *t, DBusMessageIter *
     return 0;
 }
 
+static int parse_transport_properties(pa_bluetooth_transport *t, DBusMessageIter *i) {
+    DBusMessageIter element_i;
+
+    dbus_message_iter_recurse(i, &element_i);
+
+    while (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_DICT_ENTRY) {
+        DBusMessageIter dict_i;
+
+        dbus_message_iter_recurse(&element_i, &dict_i);
+
+        if (transport_parse_property(t, &dict_i) < 0)
+            return -1;
+
+        dbus_message_iter_next(&element_i);
+    }
+
+    return 0;
+}
+
 static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *userdata) {
     DBusError err;
     pa_bluetooth_discovery *y;
@@ -1293,6 +1312,13 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* Device not being tracked */
 
             parse_device_properties(d, &arg_i);
+        } else if (pa_streq(interface, "org.bluez.MediaTransport1")) {
+            pa_bluetooth_transport *t;
+
+            if (!(t = pa_hashmap_get(y->transports, dbus_message_get_path(m))))
+                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+            parse_transport_properties(t, &arg_i);
         }
 
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -1959,6 +1985,8 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
                 "type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesRemoved'",
                 "type='signal',sender='org.bluez',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'"
                 ",arg0='org.bluez.Device1'",
+                "type='signal',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'"
+                ",arg0='org.bluez.MediaTransport1'",
                 NULL) < 0) {
         pa_log("Failed to add D-Bus matches: %s", err.message);
         goto fail;
-- 
1.7.11.7



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux