[pulseaudio-discuss] [PATCH v2 05/14] bluetooth: Parse HandsfreeAudioCard properties

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Thu Sep 11 02:14:00 PDT 2014


On Wed, 2014-09-10 at 11:48 +0200, Luiz Augusto von Dentz wrote:
> From: João Paulo Rechi Vita <jprvita at openbossa.org>
> 
> ---
>  src/modules/bluetooth/backend-ofono.c | 109 +++++++++++++++++++++++++++++++++-
>  1 file changed, 107 insertions(+), 2 deletions(-)

There are a couple of issues that I already complained about in the
previous version. Please check that you have addressed all issues that
were pointed out before sending updated patches.

In this case the remaining issues were trivial to fix, so I did the
tweaks myself (not yet pushed, but will push soon).

> +        if ((c = dbus_message_iter_get_arg_type(&value_i)) != DBUS_TYPE_STRING) {
> +            pa_log_error("Invalid properties for %s: expected \'s\', received \'%c\'", path, c);

The apostrophes don't need to be escaped.

> +            goto fail;
> +        }
> +
> +        dbus_message_iter_get_basic(&value_i, &value);
> +
> +        if (pa_streq(key, "RemoteAddress")) {
> +            pa_xfree(card->remote_address);
> +            card->remote_address = pa_xstrdup(value);
> +        } else if (pa_streq(key, "LocalAddress")) {
> +            pa_xfree(card->local_address);
> +            card->local_address = pa_xstrdup(value);
> +        }
> +
> +        pa_log_debug("%s: %s", key, value);
> +
> +        dbus_message_iter_next(props_i);
> +    }
> +
> +    pa_hashmap_put(backend->cards, card->path, card);
> +
> +    d = pa_bluetooth_discovery_get_device_by_address(backend->discovery, card->remote_address, card->local_address);
> +    if (d) {
> +        card->transport = pa_bluetooth_transport_new(d, backend->ofono_bus_id, path, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY, NULL, 0);
> +        card->transport->acquire = hf_audio_agent_transport_acquire;
> +        card->transport->release = hf_audio_agent_transport_release;
> +        card->transport->userdata = card;
> +
> +        pa_bluetooth_transport_put(card->transport);
> +    } else
> +        pa_log_error("Device doesnt exist for %s", path);
> +
> +    return;
> +
> +fail:
> +    pa_xfree(card);

Use hf_audio_card_free() to make sure you don't leak any of the struct
members.

-- 
Tanu



More information about the pulseaudio-discuss mailing list