Make OSS_CloseDevice more resilient

Francois Gouget fgouget at codeweavers.com
Wed Jan 15 01:36:56 CST 2003


This is to prevent things from going wrong in weird ways if 
OSS_CloseDevice is called more than OSS_OpenDevice.

Changelog:

    Francois Gouget <fgouget at codeweavers.com>

  * dlls/winmm/wineoss/audio.c

    Warn if open_count is already 0 when OSS_CloseDevice is called.
    Don't decrement it in that case.


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/winmm/wineoss/audio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.71
diff -u -r1.71 audio.c
--- dlls/winmm/wineoss/audio.c	11 Jan 2003 22:47:51 -0000	1.71
+++ dlls/winmm/wineoss/audio.c	14 Jan 2003 19:16:32 -0000
@@ -374,7 +449,12 @@
  */
 static void	OSS_CloseDevice(OSS_DEVICE* ossdev)
 {
-    if (--ossdev->open_count == 0)
+    if (ossdev->open_count>0) {
+        ossdev->open_count--;
+    } else {
+        WARN("OSS_CloseDevice called too many times\n");
+    }
+    if (ossdev->open_count == 0)
     {
        /* reset the device before we close it in case it is in a bad state */
        ioctl(ossdev->fd, SNDCTL_DSP_RESET, 0);


More information about the wine-patches mailing list