]> git.alsa-project.org Git - alsa-utils.git/commitdiff
fixes by Clemens Ladisch <clemens@ladisch.de>:
authorTakashi Iwai <tiwai@suse.de>
Fri, 20 Jun 2003 18:13:28 +0000 (18:13 +0000)
committerTakashi Iwai <tiwai@suse.de>
Fri, 20 Jun 2003 18:13:28 +0000 (18:13 +0000)
- fixed the check of wrong variable.
- suppress the "no state is present..." message if the card has
  no controls.

alsactl/alsactl.c

index f8b91239f2e756d361cc5a40bd7b5cf63fa17dad..4b921531e94c363e46e99b70bb807dddfcd9d7af 100644 (file)
@@ -507,7 +507,7 @@ static int get_controls(int cardno, snd_config_t *top)
        }
        err = snd_config_search(state, id, &card);
        if (err == 0 &&
-           snd_config_get_type(state) != SND_CONFIG_TYPE_COMPOUND) {
+           snd_config_get_type(card) != SND_CONFIG_TYPE_COMPOUND) {
                error("config state.%s node is not a compound", id);
                err = -EINVAL;
                goto _close;
@@ -527,18 +527,22 @@ static int get_controls(int cardno, snd_config_t *top)
                        goto _close;
                }
        }
-       err = snd_config_compound_add(card, "control", 1, &control);
-       if (err < 0) {
-               error("snd_config_compound_add: %s", snd_strerror(err));
-               goto _close;
-       }
        err = snd_ctl_elem_list(handle, list);
        if (err < 0) {
                error("Cannot determine controls: %s", snd_strerror(err));
                goto _close;
        }
        count = snd_ctl_elem_list_get_count(list);
-       if (count <= 0) {
+       if (count < 0) {
+               err = 0;
+               goto _close;
+       }
+       err = snd_config_compound_add(card, "control", count > 0, &control);
+       if (err < 0) {
+               error("snd_config_compound_add: %s", snd_strerror(err));
+               goto _close;
+       }
+       if (count == 0) {
                err = 0;
                goto _close;
        }