Fix in wineoss.OSS_RawOpenDevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




In cases where waveOutOpen is called with an unsupported format we would 
not return an error. I tracked it down to OSS_RawOpenDevice which issued 
a debug message but did not return an error. So I modified it to return 
an error if the format was not accepted by OSS so that higher layers can 
take appropriate actions.


Changelog:

    Francois Gouget <fgouget@codeweavers.com>

  * dlls/winmm/wineoss/audio.c

    OSS_RawOpenDevice should return an error if the format is not supported


-- 
Francois Gouget
fgouget@codeweavers.com

Index: dlls/winmm/wineoss/audio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.64
diff -u -r1.64 audio.c
--- dlls/winmm/wineoss/audio.c	9 Oct 2002 20:37:09 -0000	1.64
+++ dlls/winmm/wineoss/audio.c	4 Nov 2002 08:48:06 -0000
@@ -240,7 +240,7 @@
  */
 static DWORD      OSS_RawOpenDevice(OSS_DEVICE* ossdev, int* frag)
 {
-    int fd, val;
+    int fd, val, err;
 
     if ((fd = open(ossdev->dev_name, ossdev->open_access|O_NDELAY, 0)) == -1)
     {
@@ -262,25 +262,38 @@
     {
         val = ossdev->format;
         ioctl(fd, SNDCTL_DSP_SETFMT, &val);
-        if (val != ossdev->format)
-            ERR("Can't set format to %d (%d)\n", ossdev->format, val);
+        if (val != ossdev->format) {
+            ERR("Can't set format to %d (returned %d)\n", val, ossdev->format);
+            err=WAVERR_BADFORMAT;
+            goto error;
+        }
     }
     if (ossdev->stereo)
     {
         val = ossdev->stereo;
         ioctl(fd, SNDCTL_DSP_STEREO, &val);
-        if (val != ossdev->stereo)
-            ERR("Can't set stereo to %u (%d)\n", ossdev->stereo, val);
+        if (val != ossdev->stereo) {
+            ERR("Can't set stereo to %u (returned %d)\n", val, ossdev->stereo);
+            err=WAVERR_BADFORMAT;
+            goto error;
+        }
     }
     if (ossdev->sample_rate)
     {
         val = ossdev->sample_rate;
         ioctl(fd, SNDCTL_DSP_SPEED, &ossdev->sample_rate);
-        if (!NEAR_MATCH(val, ossdev->sample_rate))
-            ERR("Can't set sample_rate to %u (%d)\n", ossdev->sample_rate, val);
+        if (!NEAR_MATCH(val, ossdev->sample_rate)) {
+            ERR("Can't set sample_rate to %u (returned %d)\n", val, ossdev->sample_rate);
+            err=WAVERR_BADFORMAT;
+            goto error;
+        }
     }
     ossdev->fd = fd;
     return MMSYSERR_NOERROR;
+
+error:
+    close(fd);
+    return err;
 }
 
 /******************************************************************

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux