[pulseaudio-discuss] [PATCHv2 40/60] bluetooth: Handle PropertiesChanged for org.bluez.Device1

João Paulo Rechi Vita jprvita at gmail.com
Fri Sep 13 13:06:45 PDT 2013


On Sun, Aug 18, 2013 at 9:50 AM, Tanu Kaskinen
<tanu.kaskinen at linux.intel.com> wrote:
> On Tue, 2013-08-13 at 01:54 -0300, jprvita at gmail.com wrote:
>> From: João Paulo Rechi Vita <jprvita at openbossa.org>
>>
>> ---
>>  src/modules/bluetooth/bluez5-util.c | 35 +++++++++++++++++++++++++++++++++++
>>  1 file changed, 35 insertions(+)
>>
>> diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
>> index 94e3c35..e0a5a69 100644
>> --- a/src/modules/bluetooth/bluez5-util.c
>> +++ b/src/modules/bluetooth/bluez5-util.c
>> @@ -843,6 +843,37 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
>>
>>          return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
>>
>> +    } else if (dbus_message_is_signal(m, "org.freedesktop.DBus.Properties", "PropertiesChanged")) {
>> +        DBusMessageIter arg_i;
>> +        const char *iface;
>> +
>> +        if (!y->objects_listed)
>> +            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* No reply received yet from GetManagedObjects */
>> +
>> +        if (!dbus_message_iter_init(m, &arg_i) || !pa_streq(dbus_message_get_signature(m), "sa{sv}as")) {
>> +            pa_log_error("Invalid signature found in PropertiesChanged");
>> +            goto fail;
>> +        }
>> +
>> +        dbus_message_iter_get_basic(&arg_i, &iface);
>> +
>> +        pa_assert_se(dbus_message_iter_next(&arg_i));
>> +        pa_assert(dbus_message_iter_get_arg_type(&arg_i) == DBUS_TYPE_ARRAY);
>> +
>> +        if (pa_streq(iface, BLUEZ_DEVICE_INTERFACE)) {
>> +            pa_bluetooth_device *d;
>> +
>> +            pa_log_debug("Properties changed in device %s", dbus_message_get_path(m));
>> +
>> +            if (!(d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
>> +                pa_log_warn("Properties changed in unknown device");
>> +                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
>> +            }
>> +
>> +            parse_device_properties(d, &arg_i, true);
>
> You don't check device_info_valid at all. If it's -1, the properties
> shouldn't be parsed, and if it's 0, there should be some notification
> about a new device (in addition the notification that I mentioned in the
> previous mail: if device_info_valid is 1 and parse_device_properties()
> fails, then a notification should be sent about the device becoming
> unavailable).
>

I agree when device_info_valid == -1.

If device_info_valid == 0 it means PropertiesChanged arrived before
the InterfacesAdded signal or the GetManagedObjects() reply and the
device object has been created due to a call to SetConfiguration. In
this case we should simply ignore the PropertiesChanged signal and
wait that parse_interfaces_and_properties will parse the device
properties.

-- 
João Paulo Rechi Vita
http://about.me/jprvita


More information about the pulseaudio-discuss mailing list