On Jul 18, 2013 11:25 AM, "Tanu Kaskinen" <tanu.kaskinen at linux.intel.com> wrote: > > On Fri, 2013-07-12 at 15:06 -0300, jprvita at gmail.com wrote: > > From: Jo?o Paulo Rechi Vita <jprvita at openbossa.org> > > > > 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". > Ok, I didn't remember of this requirement in PA. I'll fix this and other occurrences of this problem for the next patch series. > > +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. > You're right. This code is from the BlueZ 4 modules, so this should be fixed there as well (I'll have a look into it). For BlueZ 5 I use this function only in the oFono HFP support, and I've realized that I actually need to take the local adapter address into account as well, so I'll send an updated version of this function that takes the local and remote addresses in the next series. -- Jo?o Paulo Rechi Vita http://about.me/jprvita -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20130725/4747868f/attachment.html>