diff --git a/dlls/mmdevapi/main.c b/dlls/mmdevapi/main.c index 110c8028c76..42467580d77 100644 --- a/dlls/mmdevapi/main.c +++ b/dlls/mmdevapi/main.c @@ -109,7 +109,7 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) return TRUE; } -static BOOL init_driver(void) +static BOOL WINAPI init_driver(INIT_ONCE *once, void *param, void **context) { static const WCHAR drv_value[] = {'A','u','d','i','o',0}; @@ -120,9 +120,6 @@ static BOOL init_driver(void) HKEY key; WCHAR reg_list[256], *p, *next, *driver_list = default_list; - if(drvs.module) - return TRUE; - if(RegOpenKeyW(HKEY_CURRENT_USER, drv_keyW, &key) == ERROR_SUCCESS){ DWORD size = sizeof(reg_list); @@ -276,10 +273,11 @@ static IClassFactoryImpl MMDEVAPI_CF[] = { HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { + static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; unsigned int i = 0; TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); - if(!init_driver()){ + if(!InitOnceExecuteOnce(&init_once, init_driver, NULL, NULL)) { ERR("Driver initialization failed\n"); return E_FAIL; }