mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-17 08:56:42 -05:00
bluetooth: Track discovery modules by index
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.
This commit is contained in:
parent
b402f9e01f
commit
9490a067bb
1 changed files with 20 additions and 11 deletions
|
|
@ -35,24 +35,33 @@ PA_MODULE_VERSION(PACKAGE_VERSION);
|
||||||
PA_MODULE_LOAD_ONCE(true);
|
PA_MODULE_LOAD_ONCE(true);
|
||||||
|
|
||||||
struct userdata {
|
struct userdata {
|
||||||
pa_module *bluez5_module;
|
uint32_t bluez5_module_idx;
|
||||||
pa_module *bluez4_module;
|
uint32_t bluez4_module_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
int pa__init(pa_module* m) {
|
int pa__init(pa_module* m) {
|
||||||
struct userdata *u;
|
struct userdata *u;
|
||||||
|
pa_module *mm;
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
m->userdata = u = pa_xnew0(struct userdata, 1);
|
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||||
|
u->bluez5_module_idx = PA_INVALID_INDEX;
|
||||||
|
u->bluez4_module_idx = PA_INVALID_INDEX;
|
||||||
|
|
||||||
if (pa_module_exists("module-bluez5-discover"))
|
if (pa_module_exists("module-bluez5-discover")) {
|
||||||
u->bluez5_module = pa_module_load(m->core, "module-bluez5-discover", NULL);
|
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"))
|
if (pa_module_exists("module-bluez4-discover")) {
|
||||||
u->bluez4_module = pa_module_load(m->core, "module-bluez4-discover", NULL);
|
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 == PA_INVALID_INDEX && u->bluez4_module_idx == PA_INVALID_INDEX) {
|
||||||
pa_xfree(u);
|
pa_xfree(u);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -68,11 +77,11 @@ void pa__done(pa_module* m) {
|
||||||
if (!(u = m->userdata))
|
if (!(u = m->userdata))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (u->bluez5_module)
|
if (u->bluez5_module_idx != PA_INVALID_INDEX)
|
||||||
pa_module_unload(m->core, u->bluez5_module, true);
|
pa_module_unload_by_index(m->core, u->bluez5_module_idx, true);
|
||||||
|
|
||||||
if (u->bluez4_module)
|
if (u->bluez4_module_idx != PA_INVALID_INDEX)
|
||||||
pa_module_unload(m->core, u->bluez4_module, true);
|
pa_module_unload_by_index(m->core, u->bluez4_module_idx, true);
|
||||||
|
|
||||||
pa_xfree(u);
|
pa_xfree(u);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue