[host] fix crash on screen blanking

This commit is contained in:
Geoffrey McRae 2018-06-01 00:38:15 +10:00
parent 14954cc426
commit 8a9d0b0bfb
3 changed files with 18 additions and 16 deletions

View File

@ -614,7 +614,7 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs
return GRAB_STATUS_OK; return GRAB_STATUS_OK;
} }
if (!SUCCEEDED(status)) if (FAILED(status))
break; break;
m_releaseFrame = true; m_releaseFrame = true;
@ -657,7 +657,7 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs
DXGI_OUTDUPL_POINTER_SHAPE_INFO shapeInfo; DXGI_OUTDUPL_POINTER_SHAPE_INFO shapeInfo;
status = m_dup->GetFramePointerShape(m_pointerBufSize, m_pointer, &m_pointerSize, &shapeInfo); status = m_dup->GetFramePointerShape(m_pointerBufSize, m_pointer, &m_pointerSize, &shapeInfo);
if (!SUCCEEDED(status)) if (FAILED(status))
{ {
DEBUG_WINERROR("Failed to get the new pointer shape", status); DEBUG_WINERROR("Failed to get the new pointer shape", status);
return GRAB_STATUS_ERROR; return GRAB_STATUS_ERROR;
@ -681,14 +681,19 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs
cursor.dataSize = m_pointerSize; cursor.dataSize = m_pointerSize;
} }
// if we also have frame data // if we also have frame data, break out to process it
if (frameInfo.LastPresentTime.QuadPart != 0) if (frameInfo.LastPresentTime.QuadPart != 0)
break; break;
// no frame data, clean up
SafeRelease(&res); SafeRelease(&res);
ReleaseFrame();
// if the cursor has been updated
if (cursor.updated) if (cursor.updated)
return GRAB_STATUS_CURSOR; return GRAB_STATUS_CURSOR;
// otherwise just try again
} }
if (SUCCEEDED(status)) if (SUCCEEDED(status))
@ -762,12 +767,6 @@ GrabStatus Capture::DXGI::GrabFrameRaw(FrameInfo & frame, struct CursorInfo & cu
while(true) while(true)
{ {
result = GrabFrameTexture(frame, cursor, src, timeout); result = GrabFrameTexture(frame, cursor, src, timeout);
if (result != GRAB_STATUS_OK)
{
ReleaseFrame();
return result;
}
if (timeout) if (timeout)
{ {
if (!m_surfaceMapped) if (!m_surfaceMapped)
@ -786,10 +785,6 @@ GrabStatus Capture::DXGI::GrabFrameRaw(FrameInfo & frame, struct CursorInfo & cu
break; break;
} }
m_deviceContext->CopyResource(m_texture, src);
SafeRelease(&src);
result = ReleaseFrame();
if (result != GRAB_STATUS_OK) if (result != GRAB_STATUS_OK)
return result; return result;
@ -799,6 +794,13 @@ GrabStatus Capture::DXGI::GrabFrameRaw(FrameInfo & frame, struct CursorInfo & cu
m_surfaceMapped = false; m_surfaceMapped = false;
} }
m_deviceContext->CopyResource(m_texture, src);
SafeRelease(&src);
result = ReleaseFrame();
if (result != GRAB_STATUS_OK)
return result;
HRESULT status; HRESULT status;
status = m_deviceContext->Map(m_texture, 0, D3D11_MAP_READ, 0, &m_mapping); status = m_deviceContext->Map(m_texture, 0, D3D11_MAP_READ, 0, &m_mapping);
if (FAILED(status)) if (FAILED(status))

View File

@ -183,10 +183,8 @@ bool Service::Process()
// wait for the host to notify that is it is ready to proceed // wait for the host to notify that is it is ready to proceed
while (true) while (true)
{ {
const uint8_t f = *flags;
// check if the client has flagged a restart // check if the client has flagged a restart
if (f & KVMFR_HEADER_FLAG_RESTART) if (*flags & KVMFR_HEADER_FLAG_RESTART)
{ {
DEBUG_INFO("Restart Requested"); DEBUG_INFO("Restart Requested");
if (!m_capture->ReInitialize()) if (!m_capture->ReInitialize())

View File

@ -115,8 +115,10 @@ int run(struct StartupArgs & args)
return -1; return -1;
while (true) while (true)
{
if (!svc->Process()) if (!svc->Process())
break; break;
}
svc->DeInitialize(); svc->DeInitialize();
return 0; return 0;