obs-amf-test: Add 2.5 second timeout for AMF test process
If the test process freezes for whatever reason, OBS would block indefinitely on reading the pipe. This commit adds a 2.5 second timeout on the AMF test process after which it will self-terminate.
This commit is contained in:
parent
68415fa08f
commit
8ab6fffec4
@ -85,12 +85,35 @@ static bool get_adapter_caps(IDXGIFactory *factory, uint32_t adapter_idx)
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD WINAPI TimeoutThread(LPVOID param)
|
||||
{
|
||||
HANDLE hMainThread = (HANDLE)param;
|
||||
|
||||
DWORD ret = WaitForSingleObject(hMainThread, 2500);
|
||||
if (ret == WAIT_TIMEOUT)
|
||||
TerminateProcess(GetCurrentProcess(), STATUS_TIMEOUT);
|
||||
|
||||
CloseHandle(hMainThread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
try {
|
||||
ComPtr<IDXGIFactory> factory;
|
||||
AMF_RESULT res;
|
||||
HRESULT hr;
|
||||
|
||||
HANDLE hMainThread;
|
||||
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
|
||||
GetCurrentProcess(), &hMainThread, 0, FALSE,
|
||||
DUPLICATE_SAME_ACCESS);
|
||||
DWORD threadId;
|
||||
HANDLE hThread;
|
||||
hThread =
|
||||
CreateThread(NULL, 0, TimeoutThread, hMainThread, 0, &threadId);
|
||||
CloseHandle(hThread);
|
||||
|
||||
/* --------------------------------------------------------- */
|
||||
/* try initializing amf, I guess */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user