]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: fix parser for sequences and fix wrong strcmp
authorJaroslav Kysela <perex@perex.cz>
Wed, 10 Nov 2010 15:06:29 +0000 (16:06 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 10 Nov 2010 15:06:29 +0000 (16:06 +0100)
The sequences are not parsed correctly. First cfg value is the command
and second value is the command argument.

Also, fix strcmp calls in ucm/main.c (reported by
abraham duenas <aduejazz@gmail.com>).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/main.c
src/ucm/parser.c
test/ucm/TestHDA/Case1.conf

index e233f4140555779bf1663c00436740fb951cb64f..a73595d8759c76af62b3c42155e511503a8b5a18 100644 (file)
@@ -774,9 +774,9 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
        pthread_mutex_lock(&uc_mgr->mutex);
        if (strcmp(identifier, "_verbs") == 0)
                err = get_verb_list(uc_mgr, list);
-        else if (strcmp(identifier, "_enadevs"))
+        else if (strcmp(identifier, "_enadevs") == 0)
                err = get_enabled_device_list(uc_mgr, list);
-        else if (strcmp(identifier, "_enamods"))
+        else if (strcmp(identifier, "_enamods") == 0)
                 err = get_enabled_modifier_list(uc_mgr, list);
         else {
                 str1 = strchr(identifier, '/');
index 1b5a43107d3dc14b60bdd2e26f2d14b7f0118d2c..69a84545553342d38465896a7441de961de838ba 100644 (file)
@@ -203,7 +203,8 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
        struct sequence_element *curr;
        snd_config_iterator_t i, next;
        snd_config_t *n;
-       int err;
+       int err, idx = 0;
+       const char *cmd = NULL;
 
        if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
                uc_error("error: compound is expected for sequence definition");
@@ -212,10 +213,19 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
 
        snd_config_for_each(i, next, cfg) {
                const char *id;
+               idx ^= 1;
                n = snd_config_iterator_entry(i);
                err = snd_config_get_id(n, &id);
                if (err < 0)
                        continue;
+               if (idx == 1) {
+                       if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) {
+                               uc_error("error: string type is expected for sequence command");
+                               return -EINVAL;
+                       }
+                       snd_config_get_string(n, &cmd);
+                       continue;
+               }
 
                /* alloc new sequence element */
                curr = calloc(1, sizeof(struct sequence_element));
@@ -223,7 +233,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
                        return -ENOMEM;
                list_add_tail(&curr->list, base);
 
-               if (strcmp(id, "cset") == 0) {
+               if (strcmp(cmd, "cset") == 0) {
                        curr->type = SEQUENCE_ELEMENT_TYPE_CSET;
                        err = parse_string(n, &curr->data.cset);
                        if (err < 0) {
@@ -233,7 +243,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
                        continue;
                }
 
-               if (strcmp(id, "usleep") == 0) {
+               if (strcmp(cmd, "usleep") == 0) {
                        curr->type = SEQUENCE_ELEMENT_TYPE_SLEEP;
                        err = snd_config_get_integer(n, &curr->data.sleep);
                        if (err < 0) {
@@ -243,7 +253,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
                        continue;
                }
 
-               if (strcmp(id, "exec") == 0) {
+               if (strcmp(cmd, "exec") == 0) {
                        curr->type = SEQUENCE_ELEMENT_TYPE_EXEC;
                        err = parse_string(n, &curr->data.exec);
                        if (err < 0) {
index 65af2600ec91c2f3bb261ce3d50d14cf9693aa73..3d8cddf8f5784672c232273aa8d4ab59aebe5603 100644 (file)
@@ -1,6 +1,7 @@
 SectionVerb {
        EnableSequence [
                exec "Case1 enable seq"
+               exec "Case1 enable seq 2"
        ]
        DisableSequence [
                exec "Case2 disable seq"