cli-command: don't exit on "module already loaded" errors

Some modules may only be loaded once, and trying to load them
twice from default.pa makes PulseAudio startup fail. While that could
be considered a user error, it's nicer to not be so strict. It's not
necessarily easy to figure what went wrong, if for example the user
plays with RAOP and adds module-raop-discover to default.pa, which first
works fine, but suddenly stops working when the user at some point
enables RAOP support in paprefs. Enabling RAOP in paprefs makes
module-gconf load the module too, so the module gets loaded twice.

This patch adds a way to differentiate module load errors, and
make cli-command ignore the error when the module is already
loaded.
This commit is contained in:
Colin Leroy 2017-08-26 11:21:15 +02:00 committed by Tanu Kaskinen
parent 1a66715320
commit f0dfddead3
23 changed files with 62 additions and 36 deletions

View file

@ -52,13 +52,13 @@ int pa__init(pa_module* m) {
u->bluez4_module_idx = PA_INVALID_INDEX;
if (pa_module_exists("module-bluez5-discover")) {
mm = pa_module_load(m->core, "module-bluez5-discover", m->argument);
pa_module_load(&mm, m->core, "module-bluez5-discover", m->argument);
if (mm)
u->bluez5_module_idx = mm->index;
}
if (pa_module_exists("module-bluez4-discover")) {
mm = pa_module_load(m->core, "module-bluez4-discover", NULL);
pa_module_load(&mm, m->core, "module-bluez4-discover", NULL);
if (mm)
u->bluez4_module_idx = mm->index;
}

View file

@ -71,6 +71,7 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
const char *s;
const char *role;
char *args;
pa_module *m = NULL;
pa_assert(c);
pa_assert(source);
@ -100,7 +101,7 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
/* Load module-loopback */
args = pa_sprintf_malloc("source=\"%s\" source_dont_move=\"true\" sink_input_properties=\"media.role=%s\"", source->name,
role);
(void) pa_module_load(c, "module-loopback", args);
(void) pa_module_load(&m, c, "module-loopback", args);
pa_xfree(args);
return PA_HOOK_OK;
@ -112,6 +113,7 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void *
const char *s;
const char *role;
char *args;
pa_module *m = NULL;
pa_assert(c);
pa_assert(sink);
@ -139,7 +141,7 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void *
/* Load module-loopback */
args = pa_sprintf_malloc("sink=\"%s\" sink_dont_move=\"true\" source_output_properties=\"media.role=%s\"", sink->name,
role);
(void) pa_module_load(c, "module-loopback", args);
(void) pa_module_load(&m, c, "module-loopback", args);
pa_xfree(args);
return PA_HOOK_OK;

View file

@ -93,7 +93,7 @@ static pa_hook_result_t load_module_for_device(pa_bluez4_discovery *y, const pa_
}
pa_log_debug("Loading module-bluez4-device %s", args);
m = pa_module_load(u->module->core, "module-bluez4-device", args);
pa_module_load(&m, u->module->core, "module-bluez4-device", args);
pa_xfree(args);
if (m) {

View file

@ -76,7 +76,7 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
char *args = pa_sprintf_malloc("path=%s autodetect_mtu=%i", d->path, (int)u->autodetect_mtu);
pa_log_debug("Loading module-bluez5-device %s", args);
m = pa_module_load(u->module->core, "module-bluez5-device", args);
pa_module_load(&m, u->module->core, "module-bluez5-device", args);
pa_xfree(args);
if (m)