[PATCH 3/7] dsound: Use OpenAL for DirectSoundCaptureEnumerate

Maarten Lankhorst m.b.lankhorst at gmail.com
Thu Dec 3 03:04:25 CST 2009


---
 dlls/dsound/dsound_main.c |   90 ++++++++++++++++++++++++--------------------
 1 files changed, 49 insertions(+), 41 deletions(-)

diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index 3e4bde9..420a9f5 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -292,6 +292,13 @@ static void load_libopenal(void)
         openal_loaded = 1;
 }
 
+const ALCchar *DSOUND_getcapturedevicestrings(void)
+{
+    const ALCchar *str = NULL;
+    str = palcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
+    return str;
+}
+
 #endif /*HAVE_OPENAL*/
 
 HRESULT mmErr(UINT err)
@@ -668,56 +675,57 @@ DirectSoundCaptureEnumerateW(
     LPDSENUMCALLBACKW lpDSEnumCallback,
     LPVOID lpContext)
 {
-    unsigned devs, wid;
-    DSDRIVERDESC desc;
-    GUID guid;
-    int err;
-    WCHAR wDesc[MAXPNAMELEN];
-    WCHAR wName[MAXPNAMELEN];
-
     TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
 
     if (lpDSEnumCallback == NULL) {
 	WARN("invalid parameter: lpDSEnumCallback == NULL\n");
         return DSERR_INVALIDPARAM;
     }
-
-    devs = waveInGetNumDevs();
-    if (devs > 0) {
-	if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
-            wid = guid.Data4[7];
-            if (wid < devs) { {
-                    err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
-                    if (err == DS_OK) {
-                        TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
-                              "Primary Sound Capture Driver",desc.szDrvname,lpContext);
-                        MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
-                                             wDesc, sizeof(wDesc)/sizeof(WCHAR) );
-                        MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
-                                             wName, sizeof(wName)/sizeof(WCHAR) );
-                        if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
-                            return DS_OK;
-                    }
-                }
-	    }
-	}
-    }
-
-    for (wid = 0; wid < devs; ++wid) {
-        err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
-	if (err == DS_OK) {
-            guid.Data4[7] = wid;
+#ifdef HAVE_OPENAL
+    else if (openal_loaded)
+    {
+        GUID guid;
+        WCHAR wDesc[MAXPNAMELEN];
+        WCHAR wName[MAXPNAMELEN];
+        const ALCchar *devstr;
+        static const WCHAR empty[] = { 0 };
+
+        EnterCriticalSection(&openal_crst);
+        devstr = DSOUND_getcapturedevicestrings();
+        if (!devstr || !*devstr)
+            goto out;
+
+        TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
+              "Primary Sound Capture Driver","",lpContext);
+        MultiByteToWideChar( CP_ACP, 0, "Primary Sound Driver", -1,
+                             wDesc, sizeof(wDesc)/sizeof(WCHAR) );
+        if (lpDSEnumCallback(NULL, wDesc, empty, lpContext) == FALSE)
+            goto out;
+
+        guid = DSOUND_capture_guid;
+        do {
             TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
-                  debugstr_guid(&guid),desc.szDesc,desc.szDrvname,lpContext);
-            MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
-                                 wDesc, sizeof(wDesc)/sizeof(WCHAR) );
-            MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
-                                 wName, sizeof(wName)/sizeof(WCHAR) );
+                  debugstr_guid(&guid),devstr,"wineal.drv",lpContext);
+            MultiByteToWideChar( CP_UNIXCP, 0, devstr, -1,
+                                 wDesc, sizeof(wDesc)/sizeof(WCHAR)-1 );
+            wDesc[sizeof(wDesc)/sizeof(WCHAR)-1] = 0;
+            MultiByteToWideChar( CP_ACP, 0, "wineal.drv", -1,
+                                 wName, sizeof(wName)/sizeof(WCHAR)-1 );
             if (lpDSEnumCallback(&guid, wDesc, wName, lpContext) == FALSE)
-                return DS_OK;
-	}
-    }
+                goto out;
+            guid.Data4[7]++;
+            devstr += strlen(devstr)+1;
+        } while (*devstr);
 
+out:
+        LeaveCriticalSection(&openal_crst);
+    }
+    else
+#endif
+    {
+        ERR("Attempting to enumerate sound cards without OpenAL support\n");
+        ERR("Please recompile wine with OpenAL for sound to work\n");
+    }
     return DS_OK;
 }
 
-- 
1.6.5.3


--------------060508090708050608040909--



More information about the wine-patches mailing list