]> git.alsa-project.org Git - alsa-utils.git/commitdiff
amixer/alsamixer: use sysdefault:<CARD> devices instead hw:<CARD>
authorJaroslav Kysela <perex@perex.cz>
Tue, 6 Apr 2021 16:38:18 +0000 (18:38 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 6 Apr 2021 18:25:58 +0000 (20:25 +0200)
The alsa-lib 1.2.5 introduced a new scheme for the default control
devices.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
alsamixer/card_select.c
alsamixer/cli.c
amixer/amixer.c

index a58c0370ce59667387e6dd55b36d6b9089dfd03a..f2ec01f4f3eb19a47927310e67134073c1b1c516 100644 (file)
@@ -125,7 +125,11 @@ static int get_cards(void)
                        fatal_alsa_error(_("cannot enumerate sound cards"), err);
                if (number < 0)
                        break;
+#if defined(SND_LIB_VER) && SND_LIB_VER(1, 2, 5) <= SND_LIB_VERSION
+               sprintf(buf, "sysdefault:%d", number);
+#else
                sprintf(buf, "hw:%d", number);
+#endif
                err = snd_ctl_open(&ctl, buf, 0);
                if (err < 0)
                        continue;
index 23d34ad0d33b331cc25405f45a19c042a21643ba..f153f280cd9fec5c31d94192c249fb0d14929074 100644 (file)
@@ -73,7 +73,7 @@ static void parse_options(int argc, char *argv[])
        };
        int option;
        int card_index;
-       static char name_buf[16];
+       static char name_buf[24];
 
        while ((option = getopt_long(argc, argv, short_options,
                                     long_options, NULL)) != -1) {
@@ -88,7 +88,11 @@ static void parse_options(int argc, char *argv[])
                                fprintf(stderr, _("invalid card index: %s\n"), optarg);
                                goto fail;
                        }
+#if defined(SND_LIB_VER) && SND_LIB_VER(1, 2, 5) <= SND_LIB_VERSION
+                       sprintf(name_buf, "sysdefault:%d", card_index);
+#else
                        sprintf(name_buf, "hw:%d", card_index);
+#endif
                        selem_regopt.device = name_buf;
                        break;
                case 'D':
index 3f078426c97459310a87e2a906fbf452ee1ffe55..8424e7bc3c9f23ff5b05ebdee4755dca918ec7fa 100644 (file)
@@ -1806,7 +1806,11 @@ int main(int argc, char *argv[])
                                int i;
                                i = snd_card_get_index(optarg);
                                if (i >= 0 && i < 32)
+#if defined(SND_LIB_VER) && SND_LIB_VER(1, 2, 5) <= SND_LIB_VERSION
+                                       sprintf(card, "sysdefault:%i", i);
+#else
                                        sprintf(card, "hw:%i", i);
+#endif
                                else {
                                        fprintf(stderr, "Invalid card number.\n");
                                        morehelp++;