summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2021-10-28 11:48:54 +0200
committerJaroslav Kysela <perex@perex.cz>2021-10-28 11:52:08 +0200
commit23198a72cd4f8f8759e650362b4adb485fc9fb12 (patch)
treef2a03d12de882fb2b4061adf15a6a23a96b03dc4
parenta6a22d82a068be01b0cabb9d87189b993c6a0fc5 (diff)
downloadalsa-lib-23198a72cd4f8f8759e650362b4adb485fc9fb12.tar.gz
ucm: suppress the no device (no UCM card) errors on request
It seems that users are confused when the UCM configuration is not ready for the particular hardware. Actually, we don't allow a fine grained message classification in alsa-lib and UCM API. Allow suppression of this specific type of messages on the application request (typically alsactl). BugLink: https://github.com/alsa-project/alsa-utils/issues/111 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--src/ucm/main.c7
-rw-r--r--src/ucm/parser.c3
-rw-r--r--src/ucm/ucm_local.h1
3 files changed, 10 insertions, 1 deletions
diff --git a/src/ucm/main.c b/src/ucm/main.c
index d4645e4a..078cfd64 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -1383,6 +1383,11 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
INIT_LIST_HEAD(&mgr->variable_list);
pthread_mutex_init(&mgr->mutex, NULL);
+ if (card_name && *card_name == '-') {
+ card_name++;
+ mgr->suppress_nodev_errors = 1;
+ }
+
err = uc_mgr_card_open(mgr);
if (err < 0) {
uc_mgr_free(mgr);
@@ -1402,6 +1407,8 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
/* get info on use_cases and verify against card */
err = import_master_config(mgr);
if (err < 0) {
+ if (err == -ENXIO && mgr->suppress_nodev_errors)
+ goto _err;
uc_error("error: failed to import %s use case configuration %d",
card_name, err);
goto _err;
diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index ee997800..e69fd31f 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -239,7 +239,8 @@ static int error_node(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
uc_error("error: failed to get Error string");
return err;
}
- uc_error("%s", s);
+ if (!uc_mgr->suppress_nodev_errors)
+ uc_error("%s", s);
free(s);
return -ENXIO;
}
diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h
index 8eb1fc7a..44791b32 100644
--- a/src/ucm/ucm_local.h
+++ b/src/ucm/ucm_local.h
@@ -227,6 +227,7 @@ struct snd_use_case_mgr {
char *comment;
int conf_format;
unsigned int ucm_card_number;
+ int suppress_nodev_errors;
/* UCM cards list */
struct list_head cards_list;