From 50bd40c775e7cf3411cdd3b38c22b29ef2a57cd6 Mon Sep 17 00:00:00 2001
From: Chris Morgan <cmorgan@alum.wpi.edu>
Date: Tue, 10 Dec 2002 19:06:51 +0000
Subject: [PATCH] Reset the oss device before we try to close it.  Fixes hang
 on startup of Starcraft due to oss device being in a bad state.

---
 dlls/winmm/wineoss/audio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/winmm/wineoss/audio.c b/dlls/winmm/wineoss/audio.c
index 8674efcaa6d..8ab64b40b15 100644
--- a/dlls/winmm/wineoss/audio.c
+++ b/dlls/winmm/wineoss/audio.c
@@ -369,7 +369,12 @@ static DWORD	OSS_OpenDevice(OSS_DEVICE* ossdev, unsigned req_access,
  */
 static void	OSS_CloseDevice(OSS_DEVICE* ossdev)
 {
-    if (--ossdev->open_count == 0) close(ossdev->fd);
+    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);
+       close(ossdev->fd);
+    }
 }
 
 /******************************************************************
-- 
GitLab