Use triggers when in pseudo fullduplex mode

Francois Gouget fgouget at codeweavers.com
Wed May 19 05:08:53 CDT 2004


When a soundcard supports fullduplex mode and an application tries to 
play some sound, we systematically open the device in fullduplex mode 
just in case the application wants to record sound later. But according 
to the URL below, on some i810 + OSS combinations bad things happen if 
we record sound but never drain the input buffer. So this patch uses 
triggers to disable the side we don't care about when opening the device.

http://crossover.codeweavers.com/pipermail/discuss/2003-December/005653.html


Changelog:

  * dlls/winmm/wineoss/audio.c

    Francois Gouget <fgouget at codeweavers.com>
    Use triggers to disable the sound input/output side we don't care 
about when in pseudo fullduplex mode.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/winmm/wineoss/audio.c
===================================================================
RCS file: /var/cvs/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.128
diff -u -r1.128 audio.c
--- a/dlls/winmm/wineoss/audio.c	11 May 2004 04:28:13 -0000	1.128
+++ b/dlls/winmm/wineoss/audio.c	11 May 2004 09:52:15 -0000
@@ -392,10 +404,19 @@
                             int sample_rate, int stereo, int fmt)
 {
     DWORD       ret;
+    DWORD open_access;
     TRACE("(%p,%u,%p,%d,%d,%d,%x)\n",ossdev,req_access,frag,strict_format,sample_rate,stereo,fmt);
 
     if (ossdev->full_duplex && (req_access == O_RDONLY || req_access == O_WRONLY))
-        req_access = O_RDWR;
+    {
+        TRACE("Opening RDWR because full_duplex=%d and req_access=%d\n",
+              ossdev->full_duplex,req_access);
+        open_access = O_RDWR;
+    }
+    else
+    {
+        open_access=req_access;
+    }
 
     /* FIXME: this should be protected, and it also contains a race with OSS_CloseDevice */
     if (ossdev->open_count == 0)
@@ -406,15 +427,28 @@
         ossdev->sample_rate = sample_rate;
         ossdev->stereo = stereo;
         ossdev->format = fmt;
-        ossdev->open_access = req_access;
+        ossdev->open_access = open_access;
         ossdev->owner_tid = GetCurrentThreadId();
 
         if ((ret = OSS_RawOpenDevice(ossdev,strict_format)) != MMSYSERR_NOERROR) return ret;
+        if (ossdev->full_duplex && ossdev->bTriggerSupport &&
+            (req_access == O_RDONLY || req_access == O_WRONLY))
+        {
+            int enable;
+            if (req_access == O_WRONLY)
+                ossdev->bInputEnabled=0;
+            else
+                ossdev->bOutputEnabled=0;
+            enable = getEnables(ossdev);
+            TRACE("Calling SNDCTL_DSP_SETTRIGGER with %x\n",enable);
+            if (ioctl(ossdev->fd, SNDCTL_DSP_SETTRIGGER, &enable) < 0)
+                ERR("ioctl(%s, SNDCTL_DSP_SETTRIGGER, %d) failed (%s)\n",ossdev->dev_name, enable, strerror(errno));
+        }
     }
     else
     {
         /* check we really open with the same parameters */
-        if (ossdev->open_access != req_access)
+        if (ossdev->open_access != open_access)
         {
             ERR("FullDuplex: Mismatch in access. Your sound device is not full duplex capable.\n");
             return WAVERR_BADFORMAT;
@@ -446,6 +480,19 @@
             WARN("Another thread is trying to access audio...\n");
             return MMSYSERR_ERROR;
         }
+        if (ossdev->full_duplex && ossdev->bTriggerSupport &&
+            (req_access == O_RDONLY || req_access == O_WRONLY))
+        {
+            int enable;
+            if (req_access == O_WRONLY)
+                ossdev->bOutputEnabled=1;
+            else
+                ossdev->bInputEnabled=1;
+            enable = getEnables(ossdev);
+            TRACE("Calling SNDCTL_DSP_SETTRIGGER with %x\n",enable);
+            if (ioctl(ossdev->fd, SNDCTL_DSP_SETTRIGGER, &enable) < 0)
+                ERR("ioctl(%s, SNDCTL_DSP_SETTRIGGER, %d) failed (%s)\n",ossdev->dev_name, enable, strerror(errno));
+        }
     }
 
     ossdev->open_count++;


More information about the wine-patches mailing list