From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winealsa.drv/mmdevdrv.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index fb81faf9d00..96a0a62d72e 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -21,6 +21,7 @@ #define COBJMACROS
#include <stdarg.h> +#include <wchar.h>
#include "windef.h" #include "winbase.h" @@ -128,9 +129,7 @@ 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 drv_key_devicesW[] = {'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','\','d','e','v','i','c','e','s',0}; +static WCHAR drv_key_devicesW[256]; static const WCHAR guidW[] = {'g','u','i','d',0};
static const IAudioClient3Vtbl AudioClient3_Vtbl; @@ -201,9 +200,22 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) switch (reason) { case DLL_PROCESS_ATTACH: + { + WCHAR buf[MAX_PATH]; + WCHAR *filename; + if(__wine_init_unix_call()) return FALSE; - break;
+ GetModuleFileNameW(dll, buf, ARRAY_SIZE(buf)); + + filename = wcsrchr(buf, '\'); + filename = filename ? filename + 1 : buf; + + swprintf(drv_key_devicesW, ARRAY_SIZE(drv_key_devicesW), + L"Software\Wine\Drivers\%s\devices", filename); + + break; + } case DLL_PROCESS_DETACH: if (reserved) break; DeleteCriticalSection(&g_sessions_lock);
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winecoreaudio.drv/mmdevdrv.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 877c1f7c3bc..8d1d14aa26f 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -18,6 +18,7 @@ #define COBJMACROS
#include <stdarg.h> +#include <wchar.h>
#include "windef.h" #include "winbase.h" @@ -125,7 +126,7 @@ typedef struct _SessionMgr { IMMDevice *device; } SessionMgr;
-static const WCHAR *drv_key_devicesW = L"Software\Wine\Drivers\winecoreaudio.drv\devices"; +static WCHAR drv_key_devicesW[256];
static HANDLE g_timer_q;
@@ -196,14 +197,27 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) switch (reason) { case DLL_PROCESS_ATTACH: + { + WCHAR buf[MAX_PATH]; + WCHAR *filename; + DisableThreadLibraryCalls(dll); if (__wine_init_unix_call()) return FALSE; + + GetModuleFileNameW(dll, buf, ARRAY_SIZE(buf)); + + filename = wcsrchr(buf, '\'); + filename = filename ? filename + 1 : buf; + + swprintf(drv_key_devicesW, ARRAY_SIZE(drv_key_devicesW), + L"Software\Wine\Drivers\%s\devices", filename); + g_timer_q = CreateTimerQueue(); if(!g_timer_q) return FALSE; break; - + } case DLL_PROCESS_DETACH: if (reserved) break; DeleteCriticalSection(&g_sessions_lock);
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/wineoss.drv/mmdevdrv.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 6993fa88d0a..166f9408416 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -19,6 +19,7 @@
#define COBJMACROS #include <stdarg.h> +#include <wchar.h>
#include "windef.h" #include "winbase.h" @@ -124,9 +125,7 @@ typedef struct _OSSDevice {
static struct list g_devices = LIST_INIT(g_devices);
-static const WCHAR drv_key_devicesW[] = {'S','o','f','t','w','a','r','e','\', - 'W','i','n','e','\','D','r','i','v','e','r','s','\', - 'w','i','n','e','o','s','s','.','d','r','v','\','d','e','v','i','c','e','s',0}; +static WCHAR drv_key_devicesW[256]; static const WCHAR guidW[] = {'g','u','i','d',0};
static CRITICAL_SECTION g_sessions_lock; @@ -207,9 +206,22 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) switch (reason) { case DLL_PROCESS_ATTACH: + { + WCHAR buf[MAX_PATH]; + WCHAR *filename; + if(__wine_init_unix_call()) return FALSE; - break;
+ GetModuleFileNameW(dll, buf, ARRAY_SIZE(buf)); + + filename = wcsrchr(buf, '\'); + filename = filename ? filename + 1 : buf; + + swprintf(drv_key_devicesW, ARRAY_SIZE(drv_key_devicesW), + L"Software\Wine\Drivers\%s\devices", filename); + + break; + } case DLL_PROCESS_DETACH: if (!reserved) {
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winepulse.drv/mmdevdrv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 20fa08d3fa7..0ad17edf2ef 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -71,7 +71,7 @@ static GUID pulse_render_guid = static GUID pulse_capture_guid = { 0x25da76d0, 0x033c, 0x4235, { 0x90, 0x02, 0x19, 0xf4, 0x88, 0x94, 0xac, 0x6f } };
-static const WCHAR *drv_key_devicesW = L"Software\Wine\Drivers\winepulse.drv\devices"; +static WCHAR drv_key_devicesW[256];
static CRITICAL_SECTION session_cs; static CRITICAL_SECTION_DEBUG session_cs_debug = { @@ -85,9 +85,20 @@ static CRITICAL_SECTION session_cs = { &session_cs_debug, -1, 0, 0, 0, 0 }; BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) { if (reason == DLL_PROCESS_ATTACH) { + WCHAR buf[MAX_PATH]; + WCHAR *filename; + DisableThreadLibraryCalls(dll); if (__wine_init_unix_call()) return FALSE; + + GetModuleFileNameW(dll, buf, ARRAY_SIZE(buf)); + + filename = wcsrchr(buf, '\'); + filename = filename ? filename + 1 : buf; + + swprintf(drv_key_devicesW, ARRAY_SIZE(drv_key_devicesW), + L"Software\Wine\Drivers\%s\devices", filename); } else if (reason == DLL_PROCESS_DETACH) { struct device_cache *device, *device_next;
Won't this mean after the move to mmdevapi.dll that all the drivers will use the same key? I'm not sure we'd want that - we'd want to allow the user to switch betwwen e.g. the alsa and pulse drivers while preserving the guids used by the respective drivers.
On Fri Mar 10 09:13:58 2023 +0000, Huw Davies wrote:
Won't this mean after the move to mmdevapi.dll that all the drivers will use the same key? I'm not sure we'd want that - we'd want to allow the user to switch betwwen e.g. the alsa and pulse drivers while preserving the guids used by the respective drivers.
In `mmdevapi` we would call `GetModuleFileName()` with the handle to the loaded driver's library.
I'll approve this so we can move forward, but at some point we may want to move the guid generation / storing to the driver - this would result in a cleaner unix_call interface (at the expense of a little more work in the driver).
This merge request was approved by Huw Davies.
On Fri Mar 10 19:38:50 2023 +0000, Huw Davies wrote:
I'll approve this so we can move forward, but at some point we may want to move the guid generation / storing to the driver - this would result in a cleaner unix_call interface (at the expense of a little more work in the driver).
The idea would be to add a function to the unixlib that returns the render and capture GUIDs. `mmdevapi` will take care of reading and writing from/to the registry.