winealsa.drv patch to enum all software devices from .asoundrc

Andrew Eikum aeikum at codeweavers.com
Thu Feb 9 11:42:41 CST 2012


On Tue, Feb 07, 2012 at 11:32:34PM +0200, Нискородов Серёжа wrote:
> Perhaps the code is not so clear and beautiful, but it works for me,
> and maybe someone wants to send it to the repository, or to correct
> and send a corrected.

One more thing, this messes up the default device selection, which
remains hard-coded for the first device. I'd suggest something like
the following to add to your patch. It chooses "default" as the
default device, or "pulse" if that doesn't exist.


@@ -147,9 +147,6 @@ static CRITICAL_SECTION_DEBUG g_sessions_lock_debug =
 static CRITICAL_SECTION g_sessions_lock = { &g_sessions_lock_debug, -1, 0, 0, 0, 0 };
 static struct list g_sessions = LIST_INIT(g_sessions);
 
-static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0};
-static const char defname[] = "default";
-
 static const IAudioClientVtbl AudioClient_Vtbl;
 static const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
 static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
@@ -435,8 +469,6 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, char ***keys,
         return E_OUTOFMEMORY;
     }
 
-    *def_index = 0;
-
     hr = alsa_enum_devices(flow, *ids, *keys, num);
     if(FAILED(hr)){
         int i;
@@ -449,6 +481,18 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, char ***keys,
         return E_OUTOFMEMORY;
     }
 
+    for(*def_index = 0; *def_index < *num; ++*def_index)
+        if(!strcmp((*keys)[*def_index], "default"))
+            break;
+
+    if(*def_index >= *num)
+        for(*def_index = 0; *def_index < *num; ++*def_index)
+            if(!strcmp((*keys)[*def_index], "pulse"))
+                break;
+
+    if(*def_index >= *num)
+        *def_index = 0;
+
     return S_OK;
 }




More information about the wine-devel mailing list