mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:05:42 +01:00
alsactl: Allow card specification by device name (support for udev)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
ef8bfcecda
commit
30744c02e7
1 changed files with 18 additions and 1 deletions
|
@ -82,9 +82,16 @@ int main(int argc, char *argv[])
|
|||
{"version", 0, NULL, 'v'},
|
||||
{NULL, 0, NULL, 0},
|
||||
};
|
||||
char *devfiles[] = {
|
||||
"/dev/snd/controlC",
|
||||
"/dev/snd/pcmC",
|
||||
"/dev/snd/midiC",
|
||||
"/dev/snd/hwC",
|
||||
NULL
|
||||
};
|
||||
char *cfgfile = SYS_ASOUNDRC;
|
||||
char *initfile = DATADIR "/init/00main";
|
||||
char *cardname;
|
||||
char *cardname, **tmp, ncardname[16];
|
||||
int removestate = 0;
|
||||
int res;
|
||||
|
||||
|
@ -143,6 +150,16 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
cardname = argc - optind > 1 ? argv[optind + 1] : NULL;
|
||||
for (tmp = devfiles; cardname != NULL && tmp != NULL; tmp++) {
|
||||
int len = strlen(*tmp);
|
||||
if (!strncmp(cardname, *tmp, len)) {
|
||||
long l = strtol(cardname + len, NULL, 0);
|
||||
sprintf(ncardname, "%li", l);
|
||||
cardname = ncardname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(argv[optind], "init")) {
|
||||
res = init(initfile, cardname);
|
||||
} else if (!strcmp(argv[optind], "store")) {
|
||||
|
|
Loading…
Reference in a new issue