fix bug that blocked stopping scene #12
This commit is contained in:
@@ -214,9 +214,11 @@ bool Duplicator::Duplicate()
|
||||
{
|
||||
if (!dupl_ || !device_) return false;
|
||||
|
||||
const UINT timeout = 16;
|
||||
|
||||
ComPtr<IDXGIResource> resource;
|
||||
DXGI_OUTDUPL_FRAME_INFO frameInfo;
|
||||
const auto hr = dupl_->AcquireNextFrame(INFINITE, &frameInfo, &resource);
|
||||
const auto hr = dupl_->AcquireNextFrame(timeout, &frameInfo, &resource);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
@@ -228,32 +230,31 @@ bool Duplicator::Duplicate()
|
||||
// it is necessary to re-initialize monitors.
|
||||
Debug::Log("Duplicator::Duplicate() => DXGI_ERROR_ACCESS_LOST.");
|
||||
state_ = State::AccessLost;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
case DXGI_ERROR_WAIT_TIMEOUT:
|
||||
{
|
||||
// This often occurs when timeout value is small and it is not problem.
|
||||
// Debug::Log("Duplicator::Duplicate() => DXGI_ERROR_WAIT_TIMEOUT.");
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
case DXGI_ERROR_INVALID_CALL:
|
||||
{
|
||||
Debug::Error("Duplicator::Duplicate() => DXGI_ERROR_INVALID_CALL.");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
case E_INVALIDARG:
|
||||
{
|
||||
Debug::Error("Duplicator::Duplicate() => E_INVALIDARG.");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
state_ = State::Unknown;
|
||||
Debug::Error("Duplicator::Duplicate() => Unknown Error.");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ScopedReleaser releaser([this]
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <d3d11.h>
|
||||
#include <dxgi1_2.h>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <wrl/client.h>
|
||||
@@ -73,7 +74,7 @@ private:
|
||||
void UpdateDirtyRects();
|
||||
|
||||
Monitor* monitor_ = nullptr;
|
||||
State state_ = State::Ready;
|
||||
std::atomic<State> state_ = State::Ready;
|
||||
|
||||
std::shared_ptr<class IsolatedD3D11Device> device_;
|
||||
Microsoft::WRL::ComPtr<IDXGIOutputDuplication> dupl_;
|
||||
|
||||
Reference in New Issue
Block a user