From: Davide Beatrici git@davidebeatrici.dev
--- dlls/mmdevapi/main.c | 19 ++++++++++++++++--- dlls/winepulse.drv/mmdevdrv.c | 4 +--- 2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/dlls/mmdevapi/main.c b/dlls/mmdevapi/main.c index 43fc03f3aa3..e67c8f8b10a 100644 --- a/dlls/mmdevapi/main.c +++ b/dlls/mmdevapi/main.c @@ -19,7 +19,9 @@
#include <stdarg.h>
+#include "ntstatus.h" #define COBJMACROS +#define WIN32_NO_STATUS #include "windef.h" #include "winbase.h" #include "wingdi.h" @@ -85,6 +87,12 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) goto fail; }
+ if ((status = __wine_unix_call(driver->module_unixlib, process_attach, NULL)) && + status != STATUS_NOT_IMPLEMENTED) { + ERR("Unable to initialize library: %lx\n", status); + goto fail; + } + #define LDFC(n) do { driver->p##n = (void*)GetProcAddress(driver->module, #n);\ if(!driver->p##n) { goto fail; } } while(0) LDFC(GetPriority); @@ -175,9 +183,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DisableThreadLibraryCalls(hinstDLL); break; case DLL_PROCESS_DETACH: - if(lpvReserved) - break; - MMDevEnum_Free(); + if (drvs.module_unixlib) { + const NTSTATUS status = __wine_unix_call(drvs.module_unixlib, process_detach, NULL); + if (status && status != STATUS_NOT_IMPLEMENTED) + WARN("Unable to deinitialize library: %lx\n", status); + } + + if (!lpvReserved) + MMDevEnum_Free(); break; }
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 5de9a941099..99dbe24c82f 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -87,14 +87,12 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) DisableThreadLibraryCalls(dll); if (__wine_init_unix_call()) return FALSE; - if (WINE_UNIX_CALL(process_attach, NULL)) - return FALSE; } else if (reason == DLL_PROCESS_DETACH) { struct device_cache *device, *device_next;
LIST_FOR_EACH_ENTRY_SAFE(device, device_next, &g_devices_cache, struct device_cache, entry) free(device); - WINE_UNIX_CALL(process_detach, NULL); + if (pulse_thread) { WaitForSingleObject(pulse_thread, INFINITE); CloseHandle(pulse_thread);