]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: suppress the no device (no UCM card) errors on request
authorJaroslav Kysela <perex@perex.cz>
Thu, 28 Oct 2021 09:48:54 +0000 (11:48 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 28 Oct 2021 09:52:08 +0000 (11:52 +0200)
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>
src/ucm/main.c
src/ucm/parser.c
src/ucm/ucm_local.h

index d4645e4add5ebabcea09e2d1137a2b59f6ae85d8..078cfd641fe76027d49ac55d1380259e0e9e4699 100644 (file)
@@ -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;
index ee9978000ec7bbb1c113269d85523db080830ab5..e69fd31f3c0141eafa5c36ca436f0fb8f0ad02af 100644 (file)
@@ -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;
 }
index 8eb1fc7a2f4dd7fbc555e9fd628921793e4e2f64..44791b3223b526d01046cecf2a8529b9ba90974c 100644 (file)
@@ -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;