Module: wine Branch: master Commit: 73cdf6530c2e463554194e11233c57251dc61a54 URL: http://source.winehq.org/git/wine.git/?a=commit;h=73cdf6530c2e463554194e1123...
Author: Andrew Eikum aeikum@codeweavers.com Date: Tue Feb 14 15:28:29 2012 -0600
winealsa.drv: Optionally load extra ALSA device names from the registry.
---
dlls/winealsa.drv/Makefile.in | 2 +- dlls/winealsa.drv/mmdevdrv.c | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/dlls/winealsa.drv/Makefile.in b/dlls/winealsa.drv/Makefile.in index 336da8b..7086ce6 100644 --- a/dlls/winealsa.drv/Makefile.in +++ b/dlls/winealsa.drv/Makefile.in @@ -1,5 +1,5 @@ MODULE = winealsa.drv -IMPORTS = uuid ole32 +IMPORTS = uuid ole32 advapi32 DELAYIMPORTS = winmm EXTRALIBS = @ALSALIBS@
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 7621423..0f710a5 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -340,6 +340,57 @@ static HRESULT alsa_get_card_devices(snd_pcm_stream_t stream, WCHAR **ids, char return S_OK; }
+static void get_reg_devices(snd_pcm_stream_t stream, WCHAR **ids, char **keys, + UINT *num) +{ + static const WCHAR drv_keyW[] = {'S','o','f','t','w','a','r','e','\', + 'W','i','n','e','\','D','r','i','v','e','r','s','\', + 'w','i','n','e','a','l','s','a','.','d','r','v',0}; + static const WCHAR ALSAOutputDevices[] = {'A','L','S','A','O','u','t','p','u','t','D','e','v','i','c','e','s',0}; + static const WCHAR ALSAInputDevices[] = {'A','L','S','A','I','n','p','u','t','D','e','v','i','c','e','s',0}; + HKEY key; + WCHAR reg_devices[256]; + DWORD size = sizeof(reg_devices), type, len; + const WCHAR *value_name = (stream == SND_PCM_STREAM_PLAYBACK) ? ALSAOutputDevices : ALSAInputDevices; + + /* @@ Wine registry key: HKCU\Software\Wine\Drivers\winealsa.drv */ + if(RegOpenKeyW(HKEY_CURRENT_USER, drv_keyW, &key) == ERROR_SUCCESS){ + if(RegQueryValueExW(key, value_name, 0, &type, + (BYTE*)reg_devices, &size) == ERROR_SUCCESS){ + WCHAR *p = reg_devices; + + if(type != REG_MULTI_SZ){ + ERR("Registry ALSA device list value type must be REG_MULTI_SZ\n"); + RegCloseKey(key); + return; + } + + while(*p){ + char devname[64]; + + WideCharToMultiByte(CP_UNIXCP, 0, p, -1, devname, sizeof(devname), NULL, NULL); + + if(alsa_try_open(devname, stream)){ + if(ids && keys){ + len = lstrlenW(p) + 1; + ids[*num] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + memcpy(ids[*num], p, len * sizeof(WCHAR)); + + len = strlen(devname) + 1; + keys[*num] = HeapAlloc(GetProcessHeap(), 0, len); + memcpy(keys[*num], devname, len); + } + ++*num; + } + + p += lstrlenW(p) + 1; + } + } + + RegCloseKey(key); + } +} + static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys, UINT *num) { @@ -360,6 +411,8 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys, ++*num; }
+ get_reg_devices(stream, ids, keys, num); + for(err = snd_card_next(&card); card != -1 && err >= 0; err = snd_card_next(&card)){ char cardpath[64];