Update of /cvsroot/alsa/alsa-oss
In directory sc8-pr-cvs1:/tmp/cvs-serv800

Modified Files:
        alsa-oss.c 
Log Message:
- suppress the error message from alsa-lib (for error opens).
- use default devices as fallback.



Index: alsa-oss.c
===================================================================
RCS file: /cvsroot/alsa/alsa-oss/alsa-oss.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- alsa-oss.c  24 Jul 2003 18:13:28 -0000      1.38
+++ alsa-oss.c  15 Oct 2003 17:06:28 -0000      1.39
@@ -433,12 +433,34 @@
        dsp->channels = 1;
        dsp->rate = 8000;
        dsp->oss_format = format;
+       result = -EINVAL;
        for (k = 0; k < 2; ++k) {
                if (!(streams & (1 << k)))
                        continue;
                result = snd_pcm_open(&dsp->streams[k].pcm, name, k, pcm_mode);
                if (result < 0)
-                       goto _error;
+                       break;
+       }
+       if (result < 0) {
+               result = 0;
+               for (k = 0; k < 2; ++k) {
+                       if (dsp->streams[k].pcm) {
+                               snd_pcm_close(dsp->streams[k].pcm);
+                               dsp->streams[k].pcm = NULL;
+                       }
+               }
+               /* try to open the default pcm as fallback */
+               if (card == 0 && (device == OSS_DEVICE_DSP || device == 
OSS_DEVICE_AUDIO))
+                       strcpy(name, "default");
+               else
+                       sprintf(name, "plughw:%d", card);
+               for (k = 0; k < 2; ++k) {
+                       if (!(streams & (1 << k)))
+                               continue;
+                       result = snd_pcm_open(&dsp->streams[k].pcm, name, k, pcm_mode);
+                       if (result < 0)
+                               goto _error;
+               }
        }
        result = oss_dsp_params(dsp);
        if (result < 0)
@@ -586,8 +608,16 @@
        if (result < 0)
                goto _error;
        result = snd_mixer_attach(mixer->mix, name);
-       if (result < 0)
-               goto _error1;
+       if (result < 0) {
+               /* try to open the default mixer as fallback */
+               if (card == 0)
+                       strcpy(name, "default");
+               else
+                       sprintf(name, "hw:%d", card);
+               result = snd_mixer_attach(mixer->mix, name);
+               if (result < 0)
+                       goto _error1;
+       }
        result = snd_mixer_selem_register(mixer->mix, NULL, NULL);
        if (result < 0)
                goto _error1;
@@ -605,6 +635,16 @@
        return -1;
 }
 
+static void error_handler(const char *file ATTRIBUTE_UNUSED,
+                         int line ATTRIBUTE_UNUSED,
+                         const char *func ATTRIBUTE_UNUSED,
+                         int err ATTRIBUTE_UNUSED,
+                         const char *fmt ATTRIBUTE_UNUSED,
+                         ...)
+{
+       /* suppress the error message from alsa-lib */
+}
+
 static int oss_open(const char *file, int oflag, ...)
 {
        int result;
@@ -620,6 +660,8 @@
                return RETRY;
        if (!S_ISCHR(s.st_mode) || ((s.st_rdev >> 8) & 0xff) != OSS_MAJOR)
                return RETRY;
+       if (! debug)
+               snd_lib_error_set_handler(error_handler);
        minor = s.st_rdev & 0xff;
        card = minor >> 4;
        device = minor & 0x0f;



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to