mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
module: Unload modules in reverse order
Unloading modules in the reverse order is the "more logical" thing to do, and speeds up shutdown somewhat, e g by not loading module-null-sink at shutdown. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
77b3ba514c
commit
0785165e5c
1 changed files with 22 additions and 1 deletions
|
|
@ -203,8 +203,29 @@ void pa_module_unload_by_index(pa_core *c, uint32_t idx, pa_bool_t force) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_module_unload_all(pa_core *c) {
|
void pa_module_unload_all(pa_core *c) {
|
||||||
pa_assert(c);
|
pa_module *m;
|
||||||
|
uint32_t *indices;
|
||||||
|
uint32_t state;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
pa_assert(c);
|
||||||
|
pa_assert(c->modules);
|
||||||
|
|
||||||
|
/* Unload modules in reverse order by default */
|
||||||
|
indices = pa_xnew(uint32_t, pa_idxset_size(c->modules));
|
||||||
|
i = 0;
|
||||||
|
PA_IDXSET_FOREACH(m, c->modules, state)
|
||||||
|
indices[i++] = state;
|
||||||
|
pa_assert(i == (int) pa_idxset_size(c->modules));
|
||||||
|
i--;
|
||||||
|
for (; i >= 0; i--) {
|
||||||
|
m = pa_idxset_remove_by_index(c->modules, indices[i]);
|
||||||
|
if (m)
|
||||||
|
pa_module_free(m);
|
||||||
|
}
|
||||||
|
pa_xfree(indices);
|
||||||
|
|
||||||
|
/* Just in case module unloading caused more modules to load */
|
||||||
pa_idxset_remove_all(c->modules, (pa_free_cb_t) pa_module_free);
|
pa_idxset_remove_all(c->modules, (pa_free_cb_t) pa_module_free);
|
||||||
|
|
||||||
if (c->module_defer_unload_event) {
|
if (c->module_defer_unload_event) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue