[PATCH] module: shuffle the sequence of acquiring the module index
Lu Guanqun
guanqun.lu at intel.com
Sun Aug 7 19:22:50 PDT 2011
With this change, we can get the module index in pa__init() function of a module.
Signed-off-by: Lu Guanqun <guanqun.lu at intel.com>
---
src/pulsecore/module.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index 8b3ff8f..73f1208 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -64,6 +64,7 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
m->argument = pa_xstrdup(argument);
m->load_once = FALSE;
m->proplist = pa_proplist_new();
+ m->index = PA_IDXSET_INVALID;
if (!(m->dl = lt_dlopenext(name))) {
pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
@@ -106,14 +107,14 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
m->core = c;
m->unload_requested = FALSE;
+ pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
+ pa_assert(m->index != PA_IDXSET_INVALID);
+
if (m->init(m) < 0) {
pa_log_error("Failed to load module \"%s\" (argument: \"%s\"): initialization failed.", name, argument ? argument : "");
goto fail;
}
- pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
- pa_assert(m->index != PA_IDXSET_INVALID);
-
pa_log_info("Loaded \"%s\" (index: #%u; argument: \"%s\").", m->name, m->index, m->argument ? m->argument : "");
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_NEW, m->index);
@@ -137,6 +138,9 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
fail:
if (m) {
+ if (m->index != PA_IDXSET_INVALID)
+ pa_idxset_remove_by_index(c->modules, m->index);
+
if (m->proplist)
pa_proplist_free(m->proplist);
--
1.7.6
--b5gNqxB1S1yM7hjW--
More information about the pulseaudio-discuss
mailing list