diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-11-09 18:25:40 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-11-09 18:25:40 +0000 |
commit | e313fe1b3d0d9f9945c41c151d72edbe9cf1ec54 (patch) | |
tree | 1e5275fb1746f7b5a90fb785be0250e6d03e9be3 /src/pulsecore/module.c | |
parent | d8e0c1c6bdb4fbfcc69d080ca78d76403f9e8760 (diff) |
tag modules that may only be loaded once at most especially, and enforce that in the module loader
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2043 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/module.c')
-rw-r--r-- | src/pulsecore/module.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c index dce91a71..e1680de5 100644 --- a/src/pulsecore/module.c +++ b/src/pulsecore/module.c @@ -46,6 +46,7 @@ #define PA_SYMBOL_INIT "pa__init" #define PA_SYMBOL_DONE "pa__done" +#define PA_SYMBOL_LOAD_ONCE "pa__load_once" #define UNLOAD_POLL_TIME 2 @@ -66,6 +67,7 @@ static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { pa_module *m = NULL; + pa_bool_t (*load_once)(void); pa_assert(c); pa_assert(name); @@ -82,6 +84,22 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { goto fail; } + if ((load_once = (pa_bool_t (*)(void)) pa_load_sym(m->dl, name, PA_SYMBOL_LOAD_ONCE))) { + + if (load_once()) { + pa_module *i; + uint32_t idx; + /* OK, the module only wants to be loaded once, let's make sure it is */ + + for (i = pa_idxset_first(c->modules, &idx); i; i = pa_idxset_next(c->modules, &idx)) { + if (strcmp(name, i->name) == 0) { + pa_log("Module \"%s\" should be loaded once at most. Refusing to load.", name); + goto fail; + } + } + } + } + if (!(m->init = (int (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_INIT))) { pa_log("Failed to load module \"%s\": symbol \""PA_SYMBOL_INIT"\" not found.", name); goto fail; |