]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Changes for auto loader..
authorJaroslav Kysela <perex@perex.cz>
Sat, 30 Jan 1999 18:35:52 +0000 (18:35 +0000)
committerJaroslav Kysela <perex@perex.cz>
Sat, 30 Jan 1999 18:35:52 +0000 (18:35 +0000)
include/control.h
src/control/cards.c
src/control/control.c
src/mixer/mixer.c
src/pcm/pcm.c
src/pcm/pcm_loopback.c
src/rawmidi/rawmidi.c
src/seq/seq.c

index 7bc33f05ad7a1d8c0bd826bd296e0af8ca839c34..c5cd4c097a00e1fcc863088071141bf62c9e9b75 100644 (file)
@@ -9,6 +9,7 @@
 extern "C" {
 #endif
 
+int snd_card_load(int card);
 int snd_cards(void);
 unsigned int snd_cards_mask(void);
 int snd_card_name(const char *name);
index 2af073da55ddc1bcec2ccce964e88197d87214e6..22821da55c9fa9c82c6c6287a388299b79d86f9e 100644 (file)
 
 #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;
        }
index 520c1a12b23bf8702c6293456f5052fda05fc778..90e32fa99e5e0543ef00ddc3f03804ad3a780d9c 100644 (file)
@@ -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;
index 8d38b4ed98e7739c0c3e05d8a6a9724f2f9a9ceb..fedfd80d8435bb51d83e4396368823d0b9ee9d94 100644 (file)
@@ -44,11 +44,15 @@ int snd_mixer_open(void **handle, int card, int device)
        snd_mixer_t *mixer;
 
        *handle = NULL;
+
        if (card < 0 || card >= SND_CARDS)
                return -EINVAL;
        sprintf(filename, SND_FILE_MIXER, card, device);
-       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_MIXER_IOCTL_PVERSION, &ver) < 0) {
                close(fd);
                return -errno;
index 6640527a9632a04d5fc346372967c2f094fea3a9..88f185977449b6f798f81d4e8af87e716f6f46af 100644 (file)
@@ -44,11 +44,15 @@ int snd_pcm_open(void **handle, int card, int device, int mode)
        snd_pcm_t *pcm;
 
        *handle = NULL;
+       
        if (card < 0 || card >= SND_CARDS)
                return -EINVAL;
        sprintf(filename, SND_FILE_PCM, card, device);
-       if ((fd = open(filename, mode)) < 0)
-               return -errno;
+       if ((fd = open(filename, mode)) < 0) {
+               snd_card_load(card);
+               if ((fd = open(filename, mode)) < 0) 
+                       return -errno;
+       }
        if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
                close(fd);
                return -errno;
index 1e6aa38db9db6ff1556f624c71ad0b1136cf8042..6db219c7c9da955a8a7c1d4cf2d27f75d7a6e12d 100644 (file)
@@ -44,12 +44,16 @@ int snd_pcm_loopback_open(void **handle, int card, int device, int mode)
        snd_pcm_loopback_t *lb;
 
        *handle = NULL;
+
        if (card < 0 || card >= SND_CARDS)
                return -EINVAL;
        sprintf(filename, SND_FILE_PCM_LB, card, device,
                mode == SND_PCM_LB_OPEN_RECORD ? "r" : "p");
-       if ((fd = open(filename, mode)) < 0)
-               return -errno;
+       if ((fd = open(filename, mode)) < 0) {
+               snd_card_load(card);
+               if ((fd = open(filename, mode)) < 0) 
+                       return -errno;
+       }
        if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
                close(fd);
                return -errno;
index 0af624d6df2888dcef3fd9923a99a9c7b9480833..6b3ac9a56fc486cc8ae9bacf59f24a207c987275 100644 (file)
@@ -44,11 +44,15 @@ int snd_rawmidi_open(void **handle, int card, int device, int mode)
        snd_rawmidi_t *rmidi;
 
        *handle = NULL;
+       
        if (card < 0 || card >= SND_CARDS)
                return -EINVAL;
        sprintf(filename, SND_FILE_RAWMIDI, card, device);
-       if ((fd = open(filename, mode)) < 0)
-               return -errno;
+       if ((fd = open(filename, mode)) < 0) {
+               snd_card_load(card);
+               if ((fd = open(filename, mode)) < 0)
+                       return -errno;
+       }
        if (ioctl(fd, SND_RAWMIDI_IOCTL_PVERSION, &ver) < 0) {
                close(fd);
                return -errno;
index a88497a2e72aa0b85ab60811c32a0891f45e6a49..31b538ca88fdc377262436fe58872635b936b7a1 100644 (file)
@@ -60,9 +60,14 @@ int snd_seq_open(void **handle, int mode)
        snd_seq_t *seq;
 
        *handle = NULL;
+
        sprintf(filename, SND_FILE_SEQ);
-       if ((fd = open(filename, mode)) < 0)
-               return -errno;
+       if ((fd = open(filename, mode)) < 0) {
+               /* 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) {
                close(fd);
                return -errno;