[pulseaudio-discuss] [RFC v0 05/15] bluetooth: Support Properties.PropertiesChanged signal
Tanu Kaskinen
tanuk at iki.fi
Sun Dec 30 06:26:26 PST 2012
On Wed, 2012-12-19 at 13:58 +0100, Mikel Astiz wrote:
> From: Mikel Astiz <mikel.astiz at bmw-carit.de>
>
> Install matches for signal Properties.PropertiesChanged and process the
> properties corresponding to the tracked devices.
> ---
> src/modules/bluetooth/bluetooth-util.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
> index d0b06b0..bf31f28 100644
> --- a/src/modules/bluetooth/bluetooth-util.c
> +++ b/src/modules/bluetooth/bluetooth-util.c
> @@ -1245,6 +1245,36 @@ 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 *interface;
> +
> + if (y->version != BLUEZ_VERSION_5)
> + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* No reply received yet from GetManagedObjects */
> +
> + if (!dbus_message_iter_init(m, &arg_i) || dbus_message_iter_get_arg_type(&arg_i) != DBUS_TYPE_STRING) {
> + pa_log("Failed to parse PropertiesChanged: %s", err.message);
> + goto fail;
> + }
Check the message signature.
> +
> + dbus_message_iter_get_basic(&arg_i, &interface);
> +
> + if (!dbus_message_iter_next(&arg_i) || dbus_message_iter_get_arg_type(&arg_i) != DBUS_TYPE_ARRAY) {
> + pa_log("Changed properties missing for interface %s", interface);
> + return -1;
> + }
> +
> + if (pa_streq(interface, "org.bluez.Device1")) {
> + pa_bluetooth_device *d;
> +
> + if (!(d = pa_hashmap_get(y->devices, dbus_message_get_path(m))))
> + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* Device not being tracked */
> +
> + if (parse_device_properties(d, &arg_i) < 0)
> + return -1;
-1 is not a valid return value. Use "goto fail" instead, or just don't
check the return value at all, since it doesn't really matter.
--
Tanu
More information about the pulseaudio-discuss
mailing list