[pulseaudio-discuss] [PATCH] bluetooth: Track discovery modules by index
João Paulo Rechi Vita
jprvita at gmail.com
Tue Oct 15 16:16:38 CEST 2013
On Tue, Oct 15, 2013 at 4:43 AM, Tanu Kaskinen
<tanu.kaskinen at linux.intel.com> wrote:
> On Mon, 2013-10-14 at 16:18 -0300, jprvita at gmail.com wrote:
>> From: João Paulo Rechi Vita <jprvita at gmail.com>
>>
>> Previously module-bluez5-discover and module-bluez4-discover were being
>> tracked using their pa_module pointer. But during daemon shutdown these
>> modules are unloaded before module-bluetooth-discover, leaving stale
>> pointers in module-bluetooth-discover's userdata. To avoid this problem
>> this commit makes module-bluetooth-discover keep track of
>> module-bluez5-discover and module-bluez4-discovery by their indexes.
>> ---
>> src/modules/bluetooth/module-bluetooth-discover.c | 29 ++++++++++++++---------
>> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> Thanks! I pushed this with a small fix (see below).
>
>> diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
>> index c4fb26a..af43a92 100644
>> --- a/src/modules/bluetooth/module-bluetooth-discover.c
>> +++ b/src/modules/bluetooth/module-bluetooth-discover.c
>> @@ -35,24 +35,31 @@ PA_MODULE_VERSION(PACKAGE_VERSION);
>> PA_MODULE_LOAD_ONCE(true);
>>
>> struct userdata {
>> - pa_module *bluez5_module;
>> - pa_module *bluez4_module;
>> + uint32_t bluez5_module_idx;
>> + uint32_t bluez4_module_idx;
>> };
>>
>> int pa__init(pa_module* m) {
>> struct userdata *u;
>> + pa_module *mm;
>>
>> pa_assert(m);
>>
>> m->userdata = u = pa_xnew0(struct userdata, 1);
>>
>> - if (pa_module_exists("module-bluez5-discover"))
>> - u->bluez5_module = pa_module_load(m->core, "module-bluez5-discover", NULL);
>> + if (pa_module_exists("module-bluez5-discover")) {
>> + mm = pa_module_load(m->core, "module-bluez5-discover", NULL);
>> + if (mm)
>> + u->bluez5_module_idx = mm->index;
>> + }
>>
>> - if (pa_module_exists("module-bluez4-discover"))
>> - u->bluez4_module = pa_module_load(m->core, "module-bluez4-discover", NULL);
>> + if (pa_module_exists("module-bluez4-discover")) {
>> + mm = pa_module_load(m->core, "module-bluez4-discover", NULL);
>> + if (mm)
>> + u->bluez4_module_idx = mm->index;
>> + }
>>
>> - if (!u->bluez5_module && !u->bluez4_module) {
>> + if (!u->bluez5_module_idx && !u->bluez4_module_idx) {
>> pa_xfree(u);
>> return -1;
>> }
>> @@ -68,11 +75,11 @@ void pa__done(pa_module* m) {
>> if (!(u = m->userdata))
>> return;
>>
>> - if (u->bluez5_module)
>> - pa_module_unload(m->core, u->bluez5_module, true);
>> + if (u->bluez5_module_idx)
>
> Zero is a valid module index. The check should be u->bluez_module_idx !=
> PA_INVALID_INDEX (also, for this to work, the variable should be
> initialized to PA_INVALID_INDEX).
>
Ok, sorry for that.
--
João Paulo Rechi Vita
http://about.me/jprvita
More information about the pulseaudio-discuss
mailing list