ucm: add possibility to skip the UCM card completely (Linked)

We have a requirement to "hide" some hardware drivers, because
other (main) UCM configuration will refer them.

This patch use special error codes to notify the upper layers
to skip the module loading.

BugLink: https://github.com/alsa-project/alsa-ucm-conf/issues/30
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2020-06-07 18:25:41 +02:00 committed by Tanu Kaskinen
parent b72724369b
commit c1a7e3c59d
6 changed files with 54 additions and 10 deletions

View file

@ -116,7 +116,7 @@ int pa_module_load(pa_module** module, pa_core *c, const char *name, const char
bool (*load_once)(void);
const char* (*get_deprecated)(void);
pa_modinfo *mi;
int errcode;
int errcode, rval;
pa_assert(module);
pa_assert(c);
@ -188,7 +188,11 @@ int pa_module_load(pa_module** module, pa_core *c, const char *name, const char
pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
pa_assert(m->index != PA_IDXSET_INVALID);
if (m->init(m) < 0) {
if ((rval = m->init(m)) < 0) {
if (rval == -PA_MODULE_ERR_SKIP) {
errcode = -PA_ERR_NOENTITY;
goto fail;
}
pa_log_error("Failed to load module \"%s\" (argument: \"%s\"): initialization failed.", name, argument ? argument : "");
errcode = -PA_ERR_IO;
goto fail;

View file

@ -30,6 +30,11 @@ typedef struct pa_module pa_module;
#include <pulsecore/core.h>
enum {
PA_MODULE_ERR_UNSPECIFIED = 1,
PA_MODULE_ERR_SKIP = 2
};
struct pa_module {
pa_core *core;
char *name, *argument;