Fixed bug with game capture not checking to see if OBS is still alive. Might adjust it later if I find a better way
This commit is contained in:
parent
3fc6a56820
commit
c01a3c0281
@ -36,6 +36,8 @@
|
||||
#define INFO_MEMORY TEXT("Local\\OBSInfoMemory")
|
||||
#define TEXTURE_MEMORY TEXT("Local\\OBSTextureMemory")
|
||||
|
||||
#define OBS_KEEPALIVE_EVENT TEXT("OBS_KeepAlive")
|
||||
|
||||
#define CAPTURETYPE_MEMORY 1
|
||||
#define CAPTURETYPE_SHAREDTEX 2
|
||||
|
||||
|
@ -200,6 +200,22 @@ void DoD3D101Capture(IDXGISwapChain *swap)
|
||||
|
||||
if(bHasTextures)
|
||||
{
|
||||
//check keep alive state, dumb but effective
|
||||
if(bCapturing)
|
||||
{
|
||||
LONGLONG curTime = OSGetTimeMicroseconds();
|
||||
if((curTime-keepAliveTime) > 3000000)
|
||||
{
|
||||
HANDLE hKeepAlive = OpenEvent(EVENT_ALL_ACCESS, FALSE, strKeepAlive.c_str());
|
||||
if(hKeepAlive)
|
||||
CloseHandle(hKeepAlive);
|
||||
else
|
||||
ClearD3D101Data();
|
||||
|
||||
keepAliveTime = curTime;
|
||||
}
|
||||
}
|
||||
|
||||
LONGLONG frameTime;
|
||||
if(bCapturing)
|
||||
{
|
||||
|
@ -201,6 +201,22 @@ void DoD3D10Capture(IDXGISwapChain *swap)
|
||||
|
||||
if(bHasTextures)
|
||||
{
|
||||
//check keep alive state, dumb but effective
|
||||
if(bCapturing)
|
||||
{
|
||||
LONGLONG curTime = OSGetTimeMicroseconds();
|
||||
if((curTime-keepAliveTime) > 3000000)
|
||||
{
|
||||
HANDLE hKeepAlive = OpenEvent(EVENT_ALL_ACCESS, FALSE, strKeepAlive.c_str());
|
||||
if(hKeepAlive)
|
||||
CloseHandle(hKeepAlive);
|
||||
else
|
||||
ClearD3D10Data();
|
||||
|
||||
keepAliveTime = curTime;
|
||||
}
|
||||
}
|
||||
|
||||
LONGLONG frameTime;
|
||||
if(bCapturing)
|
||||
{
|
||||
|
@ -234,6 +234,22 @@ void DoD3D11Capture(IDXGISwapChain *swap)
|
||||
|
||||
if(bHasTextures)
|
||||
{
|
||||
//check keep alive state, dumb but effective
|
||||
if(bCapturing)
|
||||
{
|
||||
LONGLONG curTime = OSGetTimeMicroseconds();
|
||||
if((curTime-keepAliveTime) > 3000000)
|
||||
{
|
||||
HANDLE hKeepAlive = OpenEvent(EVENT_ALL_ACCESS, FALSE, strKeepAlive.c_str());
|
||||
if(hKeepAlive)
|
||||
CloseHandle(hKeepAlive);
|
||||
else
|
||||
ClearD3D11Data();
|
||||
|
||||
keepAliveTime = curTime;
|
||||
}
|
||||
}
|
||||
|
||||
LONGLONG frameTime;
|
||||
if(bCapturing)
|
||||
{
|
||||
|
@ -611,6 +611,22 @@ void DoD3D9DrawStuff(IDirect3DDevice9 *device)
|
||||
|
||||
if(bHasTextures)
|
||||
{
|
||||
//check keep alive state, dumb but effective
|
||||
if(bCapturing)
|
||||
{
|
||||
LONGLONG curTime = OSGetTimeMicroseconds();
|
||||
if((curTime-keepAliveTime) > 3000000)
|
||||
{
|
||||
HANDLE hKeepAlive = OpenEvent(EVENT_ALL_ACCESS, FALSE, strKeepAlive.c_str());
|
||||
if(hKeepAlive)
|
||||
CloseHandle(hKeepAlive);
|
||||
else
|
||||
ClearD3D9Data();
|
||||
|
||||
keepAliveTime = curTime;
|
||||
}
|
||||
}
|
||||
|
||||
LONGLONG frameTime;
|
||||
if(bCapturing)
|
||||
{
|
||||
|
@ -42,12 +42,17 @@ LARGE_INTEGER clockFreq, startTime;
|
||||
LONGLONG prevElapsedTime;
|
||||
DWORD startTick;
|
||||
|
||||
wstring strKeepAlive;
|
||||
LONGLONG keepAliveTime = 0;
|
||||
|
||||
|
||||
void WINAPI OSInitializeTimer()
|
||||
{
|
||||
QueryPerformanceFrequency(&clockFreq);
|
||||
QueryPerformanceCounter(&startTime);
|
||||
startTick = GetTickCount();
|
||||
prevElapsedTime = 0;
|
||||
keepAliveTime = 0;
|
||||
}
|
||||
|
||||
LONGLONG WINAPI OSGetTimeMicroseconds()
|
||||
@ -262,6 +267,10 @@ DWORD WINAPI CaptureThread(HANDLE hDllMainThread)
|
||||
if(!logOutput.is_open())
|
||||
logOutput.open(lpLogPath, ios_base::in | ios_base::out | ios_base::trunc);
|
||||
|
||||
wstringstream str;
|
||||
str << OBS_KEEPALIVE_EVENT << int(GetCurrentProcessId());
|
||||
strKeepAlive = str.str();
|
||||
|
||||
WNDCLASS wc;
|
||||
ZeroMemory(&wc, sizeof(wc));
|
||||
wc.hInstance = hinstMain;
|
||||
|
@ -225,6 +225,9 @@ extern CaptureInfo *infoMem;
|
||||
|
||||
extern fstream logOutput;
|
||||
|
||||
extern wstring strKeepAlive;
|
||||
extern LONGLONG keepAliveTime;
|
||||
|
||||
void WINAPI OSInitializeTimer();
|
||||
LONGLONG WINAPI OSGetTimeMicroseconds();
|
||||
|
||||
|
@ -241,6 +241,8 @@ void GraphicsCaptureSource::EndCapture()
|
||||
capture = NULL;
|
||||
}
|
||||
|
||||
if(hOBSIsAlive)
|
||||
CloseHandle(hOBSIsAlive);
|
||||
if(hSignalRestart)
|
||||
CloseHandle(hSignalRestart);
|
||||
if(hSignalEnd)
|
||||
@ -250,7 +252,7 @@ void GraphicsCaptureSource::EndCapture()
|
||||
if(hSignalExit)
|
||||
CloseHandle(hSignalExit);
|
||||
|
||||
hSignalRestart = hSignalEnd = hSignalReady = hSignalExit = NULL;
|
||||
hSignalRestart = hSignalEnd = hSignalReady = hSignalExit = hOBSIsAlive = NULL;
|
||||
|
||||
bErrorAcquiring = false;
|
||||
|
||||
@ -344,6 +346,13 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
HANDLE hProcess = (*pOpenProcess)(PROCESS_ALL_ACCESS, FALSE, targetProcessID);
|
||||
if(hProcess)
|
||||
{
|
||||
//-------------------------------------------
|
||||
// load keepalive event
|
||||
|
||||
hOBSIsAlive = CreateEvent(NULL, FALSE, FALSE, String() << OBS_KEEPALIVE_EVENT << int(targetProcessID));
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
hwndCapture = hwndTarget;
|
||||
|
||||
hSignalRestart = OpenEvent(EVENT_ALL_ACCESS, FALSE, String() << RESTART_CAPTURE_EVENT << int(targetProcessID));
|
||||
@ -456,6 +465,12 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
|
||||
CloseHandle(hProcess);
|
||||
hProcess = NULL;
|
||||
|
||||
if (!bCapturing)
|
||||
{
|
||||
CloseHandle(hOBSIsAlive);
|
||||
hOBSIsAlive = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user