Andrew Eikum : wineoss.drv: Use a temporary OSS device to check format support.

Alexandre Julliard julliard at winehq.org
Wed Sep 28 14:45:46 CDT 2011


Module: wine
Branch: master
Commit: fdda702acd1a9ace6925845ec50edcf5e1023c79
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fdda702acd1a9ace6925845ec50edcf5e1023c79

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Wed Sep 28 13:32:03 2011 -0500

wineoss.drv: Use a temporary OSS device to check format support.

---

 dlls/wineoss.drv/mmdevdrv.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c
index 8d1a997..5de0a15 100644
--- a/dlls/wineoss.drv/mmdevdrv.c
+++ b/dlls/wineoss.drv/mmdevdrv.c
@@ -667,7 +667,7 @@ static WAVEFORMATEX *clone_format(const WAVEFORMATEX *fmt)
     return ret;
 }
 
-static HRESULT setup_oss_device(ACImpl *This, const WAVEFORMATEX *fmt,
+static HRESULT setup_oss_device(int fd, const WAVEFORMATEX *fmt,
         WAVEFORMATEX **out, BOOL query)
 {
     int tmp, oss_format;
@@ -682,7 +682,7 @@ static HRESULT setup_oss_device(ACImpl *This, const WAVEFORMATEX *fmt,
     tmp = oss_format = get_oss_format(fmt);
     if(oss_format < 0)
         return AUDCLNT_E_UNSUPPORTED_FORMAT;
-    if(ioctl(This->fd, SNDCTL_DSP_SETFMT, &tmp) < 0){
+    if(ioctl(fd, SNDCTL_DSP_SETFMT, &tmp) < 0){
         WARN("SETFMT failed: %d (%s)\n", errno, strerror(errno));
         return E_FAIL;
     }
@@ -696,7 +696,7 @@ static HRESULT setup_oss_device(ACImpl *This, const WAVEFORMATEX *fmt,
         return E_OUTOFMEMORY;
 
     tmp = fmt->nSamplesPerSec;
-    if(ioctl(This->fd, SNDCTL_DSP_SPEED, &tmp) < 0){
+    if(ioctl(fd, SNDCTL_DSP_SPEED, &tmp) < 0){
         WARN("SPEED failed: %d (%s)\n", errno, strerror(errno));
         CoTaskMemFree(closest);
         return E_FAIL;
@@ -708,7 +708,7 @@ static HRESULT setup_oss_device(ACImpl *This, const WAVEFORMATEX *fmt,
     }
 
     tmp = fmt->nChannels;
-    if(ioctl(This->fd, SNDCTL_DSP_CHANNELS, &tmp) < 0){
+    if(ioctl(fd, SNDCTL_DSP_CHANNELS, &tmp) < 0){
         WARN("CHANNELS failed: %d (%s)\n", errno, strerror(errno));
         CoTaskMemFree(closest);
         return E_FAIL;
@@ -862,7 +862,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
         return AUDCLNT_E_ALREADY_INITIALIZED;
     }
 
-    hr = setup_oss_device(This, fmt, NULL, FALSE);
+    hr = setup_oss_device(This->fd, fmt, NULL, FALSE);
     if(hr == S_FALSE){
         LeaveCriticalSection(&This->lock);
         return AUDCLNT_E_UNSUPPORTED_FORMAT;
@@ -1082,6 +1082,7 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface,
         WAVEFORMATEX **outpwfx)
 {
     ACImpl *This = impl_from_IAudioClient(iface);
+    int fd = -1;
     HRESULT ret;
 
     TRACE("(%p)->(%x, %p, %p)\n", This, mode, pwfx, outpwfx);
@@ -1098,11 +1099,20 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface,
 
     dump_fmt(pwfx);
 
-    EnterCriticalSection(&This->lock);
+    if(This->dataflow == eRender)
+        fd = open(This->ai.devnode, O_WRONLY, 0);
+    else if(This->dataflow == eCapture)
+        fd = open(This->ai.devnode, O_RDONLY, 0);
+
+    if(fd < 0){
+        ERR("Unable to open device %s: %d (%s)\n", This->ai.devnode, errno,
+                strerror(errno));
+        return AUDCLNT_E_DEVICE_INVALIDATED;
+    }
 
-    ret = setup_oss_device(This, pwfx, outpwfx, TRUE);
+    ret = setup_oss_device(fd, pwfx, outpwfx, TRUE);
 
-    LeaveCriticalSection(&This->lock);
+    close(fd);
 
     return ret;
 }




More information about the wine-cvs mailing list