amixer/alsamixer: use sysdefault:<CARD> devices instead hw:<CARD>

The alsa-lib 1.2.5 introduced a new scheme for the default control
devices.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-04-06 18:38:18 +02:00
parent 7a7e064f83
commit 0a6b63a2c4
3 changed files with 13 additions and 1 deletions

View 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;

View 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':

View 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++;