diff options
author | Jaroslav Kysela <perex@perex.cz> | 2010-11-10 16:06:29 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2010-11-10 16:06:29 +0100 |
commit | cdc9dd50bf37cc01782c9eb50dc7d217c4b79d7f (patch) | |
tree | 84730779244a6edd8a062d27351b9d5b7d1378da | |
parent | 9b6df1cf64ea7ccb329b4922d138c1f36ace00c0 (diff) | |
download | alsa-lib-cdc9dd50bf37cc01782c9eb50dc7d217c4b79d7f.tar.gz |
ucm: fix parser for sequences and fix wrong strcmp
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>
-rw-r--r-- | src/ucm/main.c | 4 | ||||
-rw-r--r-- | src/ucm/parser.c | 18 | ||||
-rw-r--r-- | test/ucm/TestHDA/Case1.conf | 1 |
3 files changed, 17 insertions, 6 deletions
diff --git a/src/ucm/main.c b/src/ucm/main.c index e233f414..a73595d8 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -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, '/'); diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 1b5a4310..69a84545 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -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) { diff --git a/test/ucm/TestHDA/Case1.conf b/test/ucm/TestHDA/Case1.conf index 65af2600..3d8cddf8 100644 --- a/test/ucm/TestHDA/Case1.conf +++ b/test/ucm/TestHDA/Case1.conf @@ -1,6 +1,7 @@ SectionVerb { EnableSequence [ exec "Case1 enable seq" + exec "Case1 enable seq 2" ] DisableSequence [ exec "Case2 disable seq" |