0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

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.
This commit is contained in:
geemion 2019-01-02 23:44:31 +08:00 committed by jp9000
parent b2bc1e159b
commit f6581952bc

View File

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