Changes for auto loader..

This commit is contained in:
Jaroslav Kysela 1999-01-30 18:35:52 +00:00
parent 9225699798
commit d0ca621a75
8 changed files with 62 additions and 15 deletions

View file

@ -9,6 +9,7 @@
extern "C" { extern "C" {
#endif #endif
int snd_card_load(int card);
int snd_cards(void); int snd_cards(void);
unsigned int snd_cards_mask(void); unsigned int snd_cards_mask(void);
int snd_card_name(const char *name); int snd_card_name(const char *name);

View file

@ -30,6 +30,22 @@
#define SND_FILE_CONTROL "/dev/snd/control%i" #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 snd_cards(void)
{ {
int idx, count; int idx, count;
@ -59,9 +75,13 @@ unsigned int snd_cards_mask(void)
if (save_mask) if (save_mask)
return save_mask; return save_mask;
for (idx = 0, mask = 0; idx < SND_CARDS; idx++) { for (idx = 0, mask = 0; idx < SND_CARDS; idx++) {
snd_card_load(idx);
sprintf(filename, SND_FILE_CONTROL, idx); sprintf(filename, SND_FILE_CONTROL, idx);
if ((fd = open(filename, O_RDWR)) < 0) if ((fd = open(filename, O_RDWR)) < 0) {
continue; snd_card_load(idx);
if ((fd = open(filename, O_RDWR)) < 0)
continue;
}
close(fd); close(fd);
mask |= 1 << idx; mask |= 1 << idx;
} }

View file

@ -42,12 +42,17 @@ int snd_ctl_open(void **handle, int card)
char filename[32]; char filename[32];
snd_ctl_t *ctl; snd_ctl_t *ctl;
*handle = NULL; *handle = NULL;
if (card < 0 || card >= SND_CARDS) if (card < 0 || card >= SND_CARDS)
return -EINVAL; return -EINVAL;
sprintf(filename, SND_FILE_CONTROL, card); sprintf(filename, SND_FILE_CONTROL, card);
if ((fd = open(filename, O_RDWR)) < 0) if ((fd = open(filename, O_RDWR)) < 0) {
return -errno; snd_card_load(card);
if ((fd = open(filename, O_RDWR)) < 0)
return -errno;
}
if (ioctl(fd, SND_CTL_IOCTL_PVERSION, &ver) < 0) { if (ioctl(fd, SND_CTL_IOCTL_PVERSION, &ver) < 0) {
close(fd); close(fd);
return -errno; return -errno;

View file

@ -44,11 +44,15 @@ int snd_mixer_open(void **handle, int card, int device)
snd_mixer_t *mixer; snd_mixer_t *mixer;
*handle = NULL; *handle = NULL;
if (card < 0 || card >= SND_CARDS) if (card < 0 || card >= SND_CARDS)
return -EINVAL; return -EINVAL;
sprintf(filename, SND_FILE_MIXER, card, device); sprintf(filename, SND_FILE_MIXER, card, device);
if ((fd = open(filename, O_RDWR)) < 0) if ((fd = open(filename, O_RDWR)) < 0) {
return -errno; snd_card_load(card);
if ((fd = open(filename, O_RDWR)) < 0)
return -errno;
}
if (ioctl(fd, SND_MIXER_IOCTL_PVERSION, &ver) < 0) { if (ioctl(fd, SND_MIXER_IOCTL_PVERSION, &ver) < 0) {
close(fd); close(fd);
return -errno; return -errno;

View file

@ -44,11 +44,15 @@ int snd_pcm_open(void **handle, int card, int device, int mode)
snd_pcm_t *pcm; snd_pcm_t *pcm;
*handle = NULL; *handle = NULL;
if (card < 0 || card >= SND_CARDS) if (card < 0 || card >= SND_CARDS)
return -EINVAL; return -EINVAL;
sprintf(filename, SND_FILE_PCM, card, device); sprintf(filename, SND_FILE_PCM, card, device);
if ((fd = open(filename, mode)) < 0) if ((fd = open(filename, mode)) < 0) {
return -errno; snd_card_load(card);
if ((fd = open(filename, mode)) < 0)
return -errno;
}
if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) { if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
close(fd); close(fd);
return -errno; return -errno;

View file

@ -44,12 +44,16 @@ int snd_pcm_loopback_open(void **handle, int card, int device, int mode)
snd_pcm_loopback_t *lb; snd_pcm_loopback_t *lb;
*handle = NULL; *handle = NULL;
if (card < 0 || card >= SND_CARDS) if (card < 0 || card >= SND_CARDS)
return -EINVAL; return -EINVAL;
sprintf(filename, SND_FILE_PCM_LB, card, device, sprintf(filename, SND_FILE_PCM_LB, card, device,
mode == SND_PCM_LB_OPEN_RECORD ? "r" : "p"); mode == SND_PCM_LB_OPEN_RECORD ? "r" : "p");
if ((fd = open(filename, mode)) < 0) if ((fd = open(filename, mode)) < 0) {
return -errno; snd_card_load(card);
if ((fd = open(filename, mode)) < 0)
return -errno;
}
if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) { if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
close(fd); close(fd);
return -errno; return -errno;

View file

@ -44,11 +44,15 @@ int snd_rawmidi_open(void **handle, int card, int device, int mode)
snd_rawmidi_t *rmidi; snd_rawmidi_t *rmidi;
*handle = NULL; *handle = NULL;
if (card < 0 || card >= SND_CARDS) if (card < 0 || card >= SND_CARDS)
return -EINVAL; return -EINVAL;
sprintf(filename, SND_FILE_RAWMIDI, card, device); sprintf(filename, SND_FILE_RAWMIDI, card, device);
if ((fd = open(filename, mode)) < 0) if ((fd = open(filename, mode)) < 0) {
return -errno; snd_card_load(card);
if ((fd = open(filename, mode)) < 0)
return -errno;
}
if (ioctl(fd, SND_RAWMIDI_IOCTL_PVERSION, &ver) < 0) { if (ioctl(fd, SND_RAWMIDI_IOCTL_PVERSION, &ver) < 0) {
close(fd); close(fd);
return -errno; return -errno;

View file

@ -60,9 +60,14 @@ int snd_seq_open(void **handle, int mode)
snd_seq_t *seq; snd_seq_t *seq;
*handle = NULL; *handle = NULL;
sprintf(filename, SND_FILE_SEQ); sprintf(filename, SND_FILE_SEQ);
if ((fd = open(filename, mode)) < 0) if ((fd = open(filename, mode)) < 0) {
return -errno; /* try load all soundcard modules */
snd_cards_mask();
if ((fd = open(filename, mode)) < 0)
return -errno;
}
if (ioctl(fd, SND_SEQ_IOCTL_PVERSION, &ver) < 0) { if (ioctl(fd, SND_SEQ_IOCTL_PVERSION, &ver) < 0) {
close(fd); close(fd);
return -errno; return -errno;