[pulseaudio-discuss] [PATCH next v1 1/7] bluetooth: Refactor parse_audio_property() to support more properties

Tanu Kaskinen tanuk at iki.fi
Mon Dec 10 20:30:06 PST 2012


On Mon, 2012-12-10 at 08:30 +0100, Mikel Astiz wrote:
> From: Mikel Astiz <mikel.astiz at bmw-carit.de>
> 
> The old implementation is limited to parsing the profile state, but
> the D-Bus API actually exposes many more properties that are currently
> not being considered, specially within org.bluez.Headset.

Thanks, applied with three trivial changes:

> -static int parse_audio_property(pa_bluetooth_discovery *u, int *state, DBusMessageIter *i) {
> +static int parse_audio_property(pa_bluetooth_device *d, const char *interface, DBusMessageIter *i) {
>      const char *key;
>      DBusMessageIter variant_i;
> +    bool is_audio_interface;
> +    enum profile p = PROFILE_OFF;
>  
> -    pa_assert(u);
> -    pa_assert(state);
> +    pa_assert(d);
> +    pa_assert(i);

Null check for interface missing.

> +
> +    if (!(is_audio_interface = pa_streq(interface, "org.bluez.Audio")))
> +        if (profile_from_interface(interface, &p) < 0)
> +            return 0; /* Interface not known so silently ignore property */
>  
>      key = check_variant_property(i);
>      if (key == NULL)
> @@ -478,8 +484,21 @@ static int parse_audio_property(pa_bluetooth_discovery *u, int *state, DBusMessa
>              dbus_message_iter_get_basic(&variant_i, &value);
>  
>              if (pa_streq(key, "State")) {
> -                *state = pa_bt_audio_state_from_string(value);
> +                pa_bt_audio_state_t state = pa_bt_audio_state_from_string(value);
> +
>                  pa_log_debug("dbus: property 'State' changed to value '%s'", value);

I think it would be good to include the interface in this log message.

> @@ -875,19 +883,9 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
>                  if (parse_device_property(d, &arg_i) < 0)
>                      goto fail;
>  
> -            } else if (dbus_message_has_interface(m, "org.bluez.Audio")) {
> -                if (parse_audio_property(y, &d->audio_state, &arg_i) < 0)
> +            } else if (parse_audio_property(d, dbus_message_get_interface(m), &arg_i) < 0)
>                      goto fail;

Forgot to reduce the indentation of "goto fail".

-- 
Tanu



More information about the pulseaudio-discuss mailing list