Ver código fonte

win-capture/graphics-hook: Check if mutex abandoned

It's possible that the mutexes used with shared memory capture to return
WAIT_ABANDONED if OBS is shut down abnormally while the mutex is locked.
geemion 6 anos atrás
pai
commit
f6581952bc
1 arquivos alterados com 7 adições e 2 exclusões
  1. 7 2
      plugins/win-capture/graphics-hook/graphics-hook.c

+ 7 - 2
plugins/win-capture/graphics-hook/graphics-hook.c

@@ -467,10 +467,15 @@ uint64_t os_gettime_ns(void)
 static inline int try_lock_shmem_tex(int id)
 {
 	int next = id == 0 ? 1 : 0;
+	DWORD wait_result = WAIT_FAILED;
 
-	if (WaitForSingleObject(tex_mutexes[id], 0) == WAIT_OBJECT_0) {
+	wait_result = WaitForSingleObject(tex_mutexes[id], 0);
+	if (wait_result == WAIT_OBJECT_0 || wait_result == WAIT_ABANDONED) {
 		return id;
-	} else if (WaitForSingleObject(tex_mutexes[next], 0) == WAIT_OBJECT_0) {
+	}
+
+	wait_result = WaitForSingleObject(tex_mutexes[next], 0);
+	if (wait_result == WAIT_OBJECT_0 || wait_result == WAIT_ABANDONED) {
 		return next;
 	}