Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs, Allman functions) over every source file so the tree is formatter-clean. Whitespace only -- no behavior change; full x64 + x86 suites pass. Also set SortIncludes: false in .clang-format. Windows include order is load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h / dinput.h; winsock2.h must precede windows.h), and the default alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build break. Leaving order alone keeps the manual, correct grouping.
21 lines
976 B
C++
21 lines
976 B
C++
// The acquire decision for the shared video texture's keyed mutex, factored out so it can be tested
|
|
// without a D3D device (capture/shared_texture.cpp uses it).
|
|
#pragma once
|
|
|
|
#include <windows.h> // HRESULT, S_OK, WAIT_ABANDONED, WAIT_TIMEOUT
|
|
|
|
namespace coop {
|
|
|
|
// True when an IDXGIKeyedMutex::AcquireSync result means we now HOLD the mutex and must copy + then
|
|
// release it. S_OK is the normal case. WAIT_ABANDONED is success-with-recovery: a previous owner
|
|
// (e.g. a host that crashed while holding it, then reconnected) terminated without releasing, so the
|
|
// OS hands ownership to us -- treating it as a failure would skip the copy AND leak ownership, so the
|
|
// next AcquireSync would block forever and the mirror would freeze. Timeout / hard errors mean "we
|
|
// didn't get it, skip this frame."
|
|
inline bool keyed_mutex_acquired(HRESULT acquire_result)
|
|
{
|
|
return acquire_result == S_OK || acquire_result == static_cast<HRESULT>(WAIT_ABANDONED);
|
|
}
|
|
|
|
} // namespace coop
|