wfreerdp-server: handle dxgi access lost error
This commit is contained in:
parent
9fbf1fb376
commit
be080f8536
@ -67,18 +67,28 @@ DXGI_OUTDUPL_FRAME_INFO FrameInfo;
|
||||
|
||||
int wf_dxgi_init(wfInfo* context)
|
||||
{
|
||||
HRESULT status;
|
||||
UINT dTop, i = 0;
|
||||
DXGI_OUTPUT_DESC desc;
|
||||
IDXGIOutput * pOutput;
|
||||
UINT DriverTypeIndex;
|
||||
IDXGIDevice* DxgiDevice = NULL;
|
||||
IDXGIAdapter* DxgiAdapter = NULL;
|
||||
IDXGIOutput* DxgiOutput = NULL;
|
||||
IDXGIOutput1* DxgiOutput1 = NULL;
|
||||
|
||||
//not sure if needed
|
||||
gAcquiredDesktopImage = NULL;
|
||||
|
||||
if (wf_dxgi_createDevice(context) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (wf_dxgi_getDuplication(context) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int wf_dxgi_createDevice(wfInfo* context)
|
||||
{
|
||||
HRESULT status;
|
||||
UINT DriverTypeIndex;
|
||||
|
||||
for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex)
|
||||
{
|
||||
/*status = D3D11CreateDevice(NULL, DriverTypes[DriverTypeIndex], NULL, D3D11_CREATE_DEVICE_DEBUG, FeatureLevels, NumFeatureLevels,
|
||||
@ -117,6 +127,20 @@ int wf_dxgi_init(wfInfo* context)
|
||||
*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wf_dxgi_getDuplication(wfInfo* context)
|
||||
{
|
||||
HRESULT status;
|
||||
UINT dTop, i = 0;
|
||||
DXGI_OUTPUT_DESC desc;
|
||||
IDXGIOutput * pOutput;
|
||||
IDXGIDevice* DxgiDevice = NULL;
|
||||
IDXGIAdapter* DxgiAdapter = NULL;
|
||||
IDXGIOutput* DxgiOutput = NULL;
|
||||
IDXGIOutput1* DxgiOutput1 = NULL;
|
||||
|
||||
status = gDevice->lpVtbl->QueryInterface(gDevice, &IID_IDXGIDevice, (void**) &DxgiDevice);
|
||||
|
||||
if (FAILED(status))
|
||||
@ -200,6 +224,7 @@ int wf_dxgi_init(wfInfo* context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wf_dxgi_cleanup(wfInfo* wfi)
|
||||
{
|
||||
if (wfi->framesWaiting > 0)
|
||||
@ -261,6 +286,14 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout)
|
||||
}
|
||||
|
||||
if (FAILED(status))
|
||||
{
|
||||
if (status == DXGI_ERROR_ACCESS_LOST)
|
||||
{
|
||||
_tprintf(_T("Failed to acquire next frame with status=%#X\n"), status);
|
||||
_tprintf(_T("Trying to reinitialize due to ACCESS LOST..."));
|
||||
wf_dxgi_getDuplication(wfi);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tprintf(_T("Failed to acquire next frame with status=%#X\n"), status);
|
||||
_tprintf(_T("\tAccumulated Frames: %d\n\tRects: %d\n\tBuffSize: %d\n"),
|
||||
@ -277,6 +310,7 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout)
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
status = DesktopResource->lpVtbl->QueryInterface(DesktopResource, &IID_ID3D11Texture2D, (void**) &gAcquiredDesktopImage);
|
||||
DesktopResource->lpVtbl->Release(DesktopResource);
|
||||
|
@ -24,6 +24,10 @@
|
||||
|
||||
int wf_dxgi_init(wfInfo* context);
|
||||
|
||||
int wf_dxgi_createDevice(wfInfo* context);
|
||||
|
||||
int wf_dxgi_getDuplication(wfInfo* context);
|
||||
|
||||
int wf_dxgi_cleanup(wfInfo* context);
|
||||
|
||||
int wf_dxgi_nextFrame(wfInfo* context, UINT timeout);
|
||||
|
Loading…
Reference in New Issue
Block a user