mmdevapi: Use InitOnce to initialize audio drivers.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2017-02-17 09:34:25 +01:00 committed by Alexandre Julliard
parent 93959d21e9
commit db0518507a
1 changed files with 3 additions and 5 deletions

View File

@ -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;
}