warn:wave:OSS_OpenDevice Another thread is trying to access audio...

Eric Pouech eric.pouech at wanadoo.fr
Wed Apr 3 00:20:50 CST 2002


> I forgot to attach the patch so here it is.
This patch would be the correct way of fixing the issue. Would you mind
trying it?
A+
-------------- next part --------------
Index: dlls/winmm/wineoss/audio.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.54
diff -u -r1.54 audio.c
--- dlls/winmm/wineoss/audio.c	1 Apr 2002 21:02:49 -0000	1.54
+++ dlls/winmm/wineoss/audio.c	3 Apr 2002 06:16:32 -0000
@@ -199,8 +199,9 @@
  * open the device for both waveout and wavein streams...
  * this is hackish, but it's the way OSS interface is done...
  */
-static int	OSS_OpenDevice(unsigned req_access)
+static int	OSS_OpenDevice(unsigned wDevID, unsigned req_access)
 {
+    /* wDevID: is not used yet, we handle only one global device /dev/dsp */
 #ifdef USE_FULLDUPLEX
     /* FIXME: race */
     if (OSS_OpenCount == 0)
@@ -249,8 +250,9 @@
  *
  *
  */
-static void	OSS_CloseDevice(int fd)
+static void	OSS_CloseDevice(unsigned wDevID, int fd)
 {
+    /* wDevID: is not used yet, we handle only one global device /dev/dsp */
 #ifdef USE_FULLDUPLEX
     if (fd != OSS_OpenFD) FIXME("What the heck????\n");
     if (--OSS_OpenCount == 0)
@@ -290,7 +292,7 @@
     /* FIXME: only one device is supported */
     memset(&WOutDev[0].caps, 0, sizeof(WOutDev[0].caps));
 
-    if ((audio = OSS_OpenDevice(O_WRONLY)) == -1) return -1;
+    if ((audio = OSS_OpenDevice(0, O_WRONLY)) == -1) return -1;
 
     ioctl(audio, SNDCTL_DSP_RESET, 0);
 
@@ -370,7 +372,7 @@
 	    !(caps & DSP_CAP_BATCH))
 	    WOutDev[0].caps.dwSupport |= WAVECAPS_DIRECTSOUND;
     }
-    OSS_CloseDevice(audio);
+    OSS_CloseDevice(0, audio);
     TRACE("out dwFormats = %08lX, dwSupport = %08lX\n",
 	  WOutDev[0].caps.dwFormats, WOutDev[0].caps.dwSupport);
 
@@ -385,7 +387,7 @@
     
     memset(&WInDev[0].caps, 0, sizeof(WInDev[0].caps));
 
-    if ((audio = OSS_OpenDevice(O_RDONLY)) == -1) return -1;
+    if ((audio = OSS_OpenDevice(0, O_RDONLY)) == -1) return -1;
 
     ioctl(audio, SNDCTL_DSP_RESET, 0);
 
@@ -451,15 +453,15 @@
 		WInDev[0].caps.dwFormats |= WAVE_FORMAT_1S16;
 	}
     }
-    OSS_CloseDevice(audio);
+    OSS_CloseDevice(0, audio);
     TRACE("in dwFormats = %08lX\n", WInDev[0].caps.dwFormats);
 
 #ifdef USE_FULLDUPLEX
-    if ((audio = OSS_OpenDevice(O_RDWR)) == -1) return -1;
+    if ((audio = OSS_OpenDevice(0, O_RDWR)) == -1) return -1;
     if (IOCTL(audio, SNDCTL_DSP_GETCAPS, caps) == 0) {
 	OSS_FullDuplex = (caps & DSP_CAP_DUPLEX);
     }
-    OSS_CloseDevice(audio);
+    OSS_CloseDevice(0, audio);
 #endif
 
     return 0;
@@ -1069,10 +1091,12 @@
 
     if (access(SOUND_DEV, 0) != 0)
 	return MMSYSERR_NOTENABLED;
+    if (wwo->unixdev != -1) return MMSYSERR_ALLOCATED;
     /* we want to be able to mmap() the device, which means it must be opened readable,
      * otherwise mmap() will fail (at least under Linux) */
-    wwo->unixdev = OSS_OpenDevice(((dwFlags & WAVE_DIRECTSOUND) || OSS_FullDuplex) ? 
-				  O_RDWR : O_WRONLY);
+    wwo->unixdev = OSS_OpenDevice(wDevID, 
+                                  ((dwFlags & WAVE_DIRECTSOUND) || OSS_FullDuplex) ? 
+                                  O_RDWR : O_WRONLY);
     if (wwo->unixdev == -1) return MMSYSERR_ALLOCATED;
 
     fcntl(wwo->unixdev, F_SETFD, 1); /* set close on exec flag */
@@ -1129,7 +1153,7 @@
     /* Read output space info for future reference */
     if (ioctl(wwo->unixdev, SNDCTL_DSP_GETOSPACE, &info) < 0) {
 	ERR("IOCTL can't 'SNDCTL_DSP_GETOSPACE' !\n");
-        OSS_CloseDevice(wwo->unixdev);
+        OSS_CloseDevice(wDevID, wwo->unixdev);
 	wwo->unixdev = -1;
 	return MMSYSERR_NOTENABLED;
     }
@@ -1204,7 +1228,7 @@
 
         OSS_DestroyRingMessage(&wwo->msgRing);
 
-        OSS_CloseDevice(wwo->unixdev);
+        OSS_CloseDevice(wDevID, wwo->unixdev);
 	wwo->unixdev = -1;
 	wwo->dwFragmentSize = 0;
 	ret = wodNotifyClient(wwo, WOM_CLOSE, 0L, 0L);
@@ -1482,13 +1506,13 @@
 {
     DWORD	ret = 1;
     /* FIXME: For now, only one sound device (SOUND_DEV) is allowed */
-    int audio = OSS_OpenDevice(OSS_FullDuplex ? O_RDWR : O_WRONLY);
+    int audio = OSS_OpenDevice(0, OSS_FullDuplex ? O_RDWR : O_WRONLY);
     
     if (audio == -1) {
 	if (errno != EBUSY)
 	    ret = 0;
     } else {
-        OSS_CloseDevice(audio);
+        OSS_CloseDevice(0, audio);
     }
     return ret;
 }
@@ -2271,7 +2295,8 @@
     }
 
     wwi = &WInDev[wDevID];
-    if ((wwi->unixdev = OSS_OpenDevice(OSS_FullDuplex ? O_RDWR : O_RDONLY)) == -1) 
+    if (wwi->unixdev != -1) return MMSYSERR_ALLOCATED;
+    if ((wwi->unixdev = OSS_OpenDevice(wDevID, OSS_FullDuplex ? O_RDWR : O_RDONLY)) == -1) 
 	return MMSYSERR_ALLOCATED;
     fcntl(wwi->unixdev, F_SETFD, 1); /* set close on exec flag */
     if (wwi->lpQueuePtr) {
@@ -2323,7 +2348,7 @@
     IOCTL(wwi->unixdev, SNDCTL_DSP_GETBLKSIZE, fragment_size);
     if (fragment_size == -1) {
 	WARN("IOCTL can't 'SNDCTL_DSP_GETBLKSIZE' !\n");
-        OSS_CloseDevice(wwi->unixdev);
+        OSS_CloseDevice(wDevID, wwi->unixdev);
 	wwi->unixdev = -1;
 	return MMSYSERR_NOTENABLED;
     }
@@ -2366,7 +2391,7 @@
     }
 
     OSS_AddRingMessage(&wwi->msgRing, WINE_WM_CLOSING, 0, TRUE);
-    OSS_CloseDevice(wwi->unixdev);
+    OSS_CloseDevice(wDevID, wwi->unixdev);
     wwi->unixdev = -1;
     wwi->dwFragmentSize = 0;
     OSS_DestroyRingMessage(&wwi->msgRing);


More information about the wine-devel mailing list