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>
This commit is contained in:
Jaroslav Kysela 2010-11-10 16:06:29 +01:00
parent 9b6df1cf64
commit cdc9dd50bf
3 changed files with 17 additions and 6 deletions

View 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, '/');

View 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) {

View file

@ -1,6 +1,7 @@
SectionVerb {
EnableSequence [
exec "Case1 enable seq"
exec "Case1 enable seq 2"
]
DisableSequence [
exec "Case2 disable seq"