On Fri, 2013-07-12 at 15:06 -0300, [email protected] wrote:
> From: João Paulo Rechi Vita <[email protected]>
>
> Create a structure pa_bluetooth_device to store information about the
> bluetooth device and utility functions to manipulate this structure.
> ---
> src/modules/bluetooth/bluez5-util.c | 84
> +++++++++++++++++++++++++++++++++++++
> src/modules/bluetooth/bluez5-util.h | 18 ++++++++
> 2 files changed, 102 insertions(+)
>
> diff --git a/src/modules/bluetooth/bluez5-util.c
> b/src/modules/bluetooth/bluez5-util.c
> index d5f1846..574a22d 100644
> --- a/src/modules/bluetooth/bluez5-util.c
> +++ b/src/modules/bluetooth/bluez5-util.c
> @@ -44,8 +44,86 @@ struct pa_bluetooth_discovery {
> pa_dbus_connection *connection;
> bool filter_added;
> pa_hook hooks[PA_BLUETOOTH_HOOK_MAX];
> + pa_hashmap *devices;
> };
>
> +static pa_bluetooth_device*
> pa_bluetooth_discovery_create_device(pa_bluetooth_discovery *y, const char
> *path) {
Static functions shouldn't have the "pa_bluetooth" prefix. Since this
seems to be a normal object allocation function, I'd use name
"device_new".
> +pa_bluetooth_device*
> pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_discovery *y, const
> char *address) {
> + pa_bluetooth_device *d;
> + void *state = NULL;
> +
> + pa_assert(y);
> + pa_assert(PA_REFCNT_VALUE(y) > 0);
> + pa_assert(address);
> +
> + while ((d = pa_hashmap_iterate(y->devices, &state, NULL)))
> + if (pa_streq(d->address, address))
> + return d->device_info_valid == 1 ? d : NULL;
If there are two devices with the same address, this will return NULL if
the first encountered device has invalid info, even if the second device
would be ok.
--
Tanu
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss