This makes later patches smaller.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/winemac.drv/display.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index e6fb9ded7eb..461662b33b9 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -136,6 +136,21 @@ static CRITICAL_SECTION modes_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static BOOL inited_original_display_mode;
+static HANDLE get_display_device_init_mutex(void) +{ + static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0}; + HANDLE mutex = CreateMutexW(NULL, FALSE, init_mutexW); + + WaitForSingleObject(mutex, INFINITE); + return mutex; +} + +static void release_display_device_init_mutex(HANDLE mutex) +{ + ReleaseMutex(mutex); + CloseHandle(mutex); +} + static BOOL get_display_device_reg_key(char *key, unsigned len) { static const char display_device_guid_prop[] = "__wine_display_device_guid"; @@ -1673,7 +1688,6 @@ static void cleanup_devices(void) */ void macdrv_init_display_devices(BOOL force) { - static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0}; HANDLE mutex; struct macdrv_gpu *gpus = NULL; struct macdrv_adapter *adapters = NULL; @@ -1688,8 +1702,7 @@ void macdrv_init_display_devices(BOOL force) WCHAR driverW[1024]; LUID gpu_luid;
- mutex = CreateMutexW(NULL, FALSE, init_mutexW); - WaitForSingleObject(mutex, INFINITE); + mutex = get_display_device_init_mutex();
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, video_keyW, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &video_hkey, &disposition)) @@ -1757,8 +1770,7 @@ done: SetupDiDestroyDeviceInfoList(gpu_devinfo); RegCloseKey(video_hkey);
- ReleaseMutex(mutex); - CloseHandle(mutex); + release_display_device_init_mutex(mutex);
macdrv_free_gpus(gpus); macdrv_free_adapters(adapters);