mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
Changes for auto loader..
This commit is contained in:
parent
9225699798
commit
d0ca621a75
8 changed files with 62 additions and 15 deletions
|
|
@ -30,6 +30,22 @@
|
|||
|
||||
#define SND_FILE_CONTROL "/dev/snd/control%i"
|
||||
|
||||
int snd_card_load(int card)
|
||||
{
|
||||
int open_dev;
|
||||
char control[32];
|
||||
char aload[32];
|
||||
|
||||
sprintf (control, "/dev/snd/control%d",card);
|
||||
sprintf (aload, "/dev/aload%d", card);
|
||||
|
||||
if ((open_dev=open(control, O_RDONLY)) < 0) {
|
||||
close(open(aload, O_RDONLY));
|
||||
} else {
|
||||
close (open_dev);
|
||||
}
|
||||
}
|
||||
|
||||
int snd_cards(void)
|
||||
{
|
||||
int idx, count;
|
||||
|
|
@ -59,9 +75,13 @@ unsigned int snd_cards_mask(void)
|
|||
if (save_mask)
|
||||
return save_mask;
|
||||
for (idx = 0, mask = 0; idx < SND_CARDS; idx++) {
|
||||
snd_card_load(idx);
|
||||
sprintf(filename, SND_FILE_CONTROL, idx);
|
||||
if ((fd = open(filename, O_RDWR)) < 0)
|
||||
continue;
|
||||
if ((fd = open(filename, O_RDWR)) < 0) {
|
||||
snd_card_load(idx);
|
||||
if ((fd = open(filename, O_RDWR)) < 0)
|
||||
continue;
|
||||
}
|
||||
close(fd);
|
||||
mask |= 1 << idx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,17 @@ int snd_ctl_open(void **handle, int card)
|
|||
char filename[32];
|
||||
snd_ctl_t *ctl;
|
||||
|
||||
*handle = NULL;
|
||||
*handle = NULL;
|
||||
|
||||
if (card < 0 || card >= SND_CARDS)
|
||||
return -EINVAL;
|
||||
sprintf(filename, SND_FILE_CONTROL, card);
|
||||
if ((fd = open(filename, O_RDWR)) < 0)
|
||||
return -errno;
|
||||
if ((fd = open(filename, O_RDWR)) < 0) {
|
||||
snd_card_load(card);
|
||||
if ((fd = open(filename, O_RDWR)) < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (ioctl(fd, SND_CTL_IOCTL_PVERSION, &ver) < 0) {
|
||||
close(fd);
|
||||
return -errno;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue