提交 f6581952 编写于 作者: G geemion 提交者: jp9000

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.
上级 b2bc1e15
...@@ -467,10 +467,15 @@ uint64_t os_gettime_ns(void) ...@@ -467,10 +467,15 @@ uint64_t os_gettime_ns(void)
static inline int try_lock_shmem_tex(int id) static inline int try_lock_shmem_tex(int id)
{ {
int next = id == 0 ? 1 : 0; 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; 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; return next;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册