[pulseaudio-commits] 3 commits - src/modules

Tanu Kaskinen tanuk at kemper.freedesktop.org
Wed Jan 30 23:39:03 PST 2013


 src/modules/bluetooth/bluetooth-util.c |   31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

New commits:
commit 849161f0865d5a264de3b0073112bb3238e7022c
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Thu Jan 31 09:34:55 2013 +0200

    bluetooth: Fail if BlueZ tries to give duplicate device addresses.

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index d10eb97..98e795c 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -372,7 +372,11 @@ static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i, boo
                     return -1;
                 }
 
-                pa_xfree(d->address);
+                if (d->address) {
+                    pa_log("Device %s: Received a duplicate Address property.", d->path);
+                    return -1;
+                }
+
                 d->address = pa_xstrdup(value);
             }
 

commit cd23fbf94729a9bb645c7fc784d30d430703f43b
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date:   Tue Jan 29 13:10:12 2013 +0100

    bluetooth: Detect changes in constant properties
    
    The D-Bus API should guarantee that some properties remain constant and
    therefore treat changes in such properties as errors.

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 5da557a..d10eb97 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -367,6 +367,11 @@ static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i, boo
                 pa_xfree(d->alias);
                 d->alias = pa_xstrdup(value);
             } else if (pa_streq(key, "Address")) {
+                if (is_property_change) {
+                    pa_log("Device property 'Address' expected to be constant but changed for %s", d->path);
+                    return -1;
+                }
+
                 pa_xfree(d->address);
                 d->address = pa_xstrdup(value);
             }

commit b531422218d736ba0594fce7308d582b6c37c814
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date:   Tue Jan 29 13:10:11 2013 +0100

    bluetooth: Propagate to property parsers if it is initial value
    
    Add a parameter so that property parsing functions distinguish the
    initial case from property changes received later.

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 1a14c9c..5da557a 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -259,7 +259,7 @@ static const char *check_variant_property(DBusMessageIter *i) {
     return key;
 }
 
-static int parse_manager_property(pa_bluetooth_discovery *y, DBusMessageIter *i) {
+static int parse_manager_property(pa_bluetooth_discovery *y, DBusMessageIter *i, bool is_property_change) {
     const char *key;
     DBusMessageIter variant_i;
 
@@ -299,7 +299,7 @@ static int parse_manager_property(pa_bluetooth_discovery *y, DBusMessageIter *i)
     return 0;
 }
 
-static int parse_adapter_property(pa_bluetooth_discovery *y, DBusMessageIter *i) {
+static int parse_adapter_property(pa_bluetooth_discovery *y, DBusMessageIter *i, bool is_property_change) {
     const char *key;
     DBusMessageIter variant_i;
 
@@ -339,7 +339,7 @@ static int parse_adapter_property(pa_bluetooth_discovery *y, DBusMessageIter *i)
     return 0;
 }
 
-static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i) {
+static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i, bool is_property_change) {
     const char *key;
     DBusMessageIter variant_i;
 
@@ -487,7 +487,7 @@ static const char *transport_state_to_string(pa_bluetooth_transport_state_t stat
     pa_assert_not_reached();
 }
 
-static int parse_audio_property(pa_bluetooth_device *d, const char *interface, DBusMessageIter *i) {
+static int parse_audio_property(pa_bluetooth_device *d, const char *interface, DBusMessageIter *i, bool is_property_change) {
     pa_bluetooth_transport *transport;
     const char *key;
     DBusMessageIter variant_i;
@@ -710,18 +710,18 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) {
             dbus_message_iter_recurse(&element_i, &dict_i);
 
             if (dbus_message_has_interface(p->message, "org.bluez.Manager")) {
-                if (parse_manager_property(y, &dict_i) < 0)
+                if (parse_manager_property(y, &dict_i, false) < 0)
                     goto finish;
 
             } else if (dbus_message_has_interface(p->message, "org.bluez.Adapter")) {
-                if (parse_adapter_property(y, &dict_i) < 0)
+                if (parse_adapter_property(y, &dict_i, false) < 0)
                     goto finish;
 
             } else if (dbus_message_has_interface(p->message, "org.bluez.Device")) {
-                if (parse_device_property(d, &dict_i) < 0)
+                if (parse_device_property(d, &dict_i, false) < 0)
                     goto finish;
 
-            } else if (parse_audio_property(d, dbus_message_get_interface(p->message), &dict_i) < 0)
+            } else if (parse_audio_property(d, dbus_message_get_interface(p->message), &dict_i, false) < 0)
                 goto finish;
 
         }
@@ -974,10 +974,10 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
             }
 
             if (dbus_message_has_interface(m, "org.bluez.Device")) {
-                if (parse_device_property(d, &arg_i) < 0)
+                if (parse_device_property(d, &arg_i, true) < 0)
                     goto fail;
 
-            } else if (parse_audio_property(d, dbus_message_get_interface(m), &arg_i) < 0)
+            } else if (parse_audio_property(d, dbus_message_get_interface(m), &arg_i, true) < 0)
                 goto fail;
 
             if (old_any_connected != pa_bluetooth_device_any_audio_connected(d))



More information about the pulseaudio-commits mailing list