[host] flag paused when waiting for sec desktop

This commit is contained in:
Geoffrey McRae 2018-07-24 01:11:19 +10:00
parent 60070e6076
commit 5cabf155ab
4 changed files with 19 additions and 21 deletions

View File

@ -72,6 +72,16 @@ DXGI::~DXGI()
{
}
bool DXGI::CanInitialize()
{
HDESK desktop = OpenInputDesktop(0, TRUE, GENERIC_READ);
if (!desktop)
return false;
CloseDesktop(desktop);
return true;
}
bool DXGI::Initialize(CaptureOptions * options)
{
if (m_initialized)
@ -580,20 +590,6 @@ STDMETHODIMP Capture::DXGI::Invoke(IMFAsyncResult * pAsyncResult)
return status;
}
void DXGI::WaitForDesktop()
{
HDESK desktop;
do
{
desktop = OpenInputDesktop(0, TRUE, GENERIC_READ);
if (desktop)
break;
Sleep(100);
}
while (!desktop);
CloseDesktop(desktop);
}
GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct CursorInfo & cursor, ID3D11Texture2DPtr & texture, bool & timeout)
{
if (!m_initialized)
@ -705,7 +701,6 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs
// desktop switch, mode change, switch DWM on or off or Secure Desktop
case DXGI_ERROR_ACCESS_LOST:
case WAIT_ABANDONED:
WaitForDesktop();
return GRAB_STATUS_REINIT;
default:
@ -752,7 +747,6 @@ GrabStatus Capture::DXGI::ReleaseFrame()
case WAIT_ABANDONED:
case DXGI_ERROR_ACCESS_LOST:
WaitForDesktop();
return GRAB_STATUS_REINIT;
}

View File

@ -62,6 +62,7 @@ namespace Capture
const char * GetName() { return "DXGI"; }
bool CanInitialize();
bool Initialize(CaptureOptions * options);
void DeInitialize();
@ -120,9 +121,6 @@ namespace Capture
GrabStatus GrabFrameRaw (struct FrameInfo & frame, struct CursorInfo & cursor);
GrabStatus GrabFrameH264 (struct FrameInfo & frame, struct CursorInfo & cursor);
void WaitForDesktop();
long m_cRef;
CaptureOptions * m_options;

View File

@ -64,6 +64,7 @@ class ICapture
public:
virtual const char * GetName() = 0;
virtual bool CanInitialize() = 0;
virtual bool Initialize(CaptureOptions * options) = 0;
virtual void DeInitialize() = 0;
virtual bool ReInitialize() = 0;

View File

@ -238,15 +238,18 @@ bool Service::Process()
case GRAB_STATUS_REINIT:
DEBUG_INFO("ReInitialize Requested");
*flags |= KVMFR_HEADER_FLAG_PAUSED;
if(WTSGetActiveConsoleSessionId() != m_consoleSessionID)
{
DEBUG_INFO("User switch detected, waiting to regain control");
*flags |= KVMFR_HEADER_FLAG_PAUSED;
while (WTSGetActiveConsoleSessionId() != m_consoleSessionID)
Sleep(100);
*flags &= ~KVMFR_HEADER_FLAG_PAUSED;
}
while (!m_capture->CanInitialize())
Sleep(100);
if (!m_capture->ReInitialize())
{
DEBUG_ERROR("ReInitialize Failed");
@ -259,6 +262,8 @@ bool Service::Process()
return false;
}
*flags &= ~KVMFR_HEADER_FLAG_PAUSED;
// re-init request should not count towards a failure to capture
--i;
continue;