modify duplicator state handling.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -162,7 +162,12 @@ void Duplicator::Start()
|
|||||||
});
|
});
|
||||||
|
|
||||||
const auto timeout = static_cast<UINT>(frameMilliSeconds);
|
const auto timeout = static_cast<UINT>(frameMilliSeconds);
|
||||||
if (!Duplicate(timeout)) break;
|
Duplicate(timeout);
|
||||||
|
|
||||||
|
if (state_ != State::Running)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state_ == State::Running)
|
if (state_ == State::Running)
|
||||||
@@ -229,9 +234,9 @@ const Duplicator::Frame& Duplicator::GetLastFrame() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Duplicator::Duplicate(UINT timeout)
|
void Duplicator::Duplicate(UINT timeout)
|
||||||
{
|
{
|
||||||
if (!dupl_ || !device_) return false;
|
if (!dupl_ || !device_) return;
|
||||||
|
|
||||||
ComPtr<IDXGIResource> resource;
|
ComPtr<IDXGIResource> resource;
|
||||||
DXGI_OUTDUPL_FRAME_INFO frameInfo;
|
DXGI_OUTDUPL_FRAME_INFO frameInfo;
|
||||||
@@ -247,31 +252,32 @@ bool Duplicator::Duplicate(UINT timeout)
|
|||||||
// it is necessary to re-initialize monitors.
|
// it is necessary to re-initialize monitors.
|
||||||
Debug::Log("Duplicator::Duplicate() => DXGI_ERROR_ACCESS_LOST.");
|
Debug::Log("Duplicator::Duplicate() => DXGI_ERROR_ACCESS_LOST.");
|
||||||
state_ = State::AccessLost;
|
state_ = State::AccessLost;
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case DXGI_ERROR_WAIT_TIMEOUT:
|
case DXGI_ERROR_WAIT_TIMEOUT:
|
||||||
{
|
{
|
||||||
// This often occurs when timeout value is small and it is not problem.
|
// This often occurs when timeout value is small and it is not problem.
|
||||||
// Debug::Log("Duplicator::Duplicate() => DXGI_ERROR_WAIT_TIMEOUT.");
|
// Debug::Log("Duplicator::Duplicate() => DXGI_ERROR_WAIT_TIMEOUT.");
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
case DXGI_ERROR_INVALID_CALL:
|
case DXGI_ERROR_INVALID_CALL:
|
||||||
{
|
{
|
||||||
Debug::Error("Duplicator::Duplicate() => DXGI_ERROR_INVALID_CALL.");
|
Debug::Error("Duplicator::Duplicate() => DXGI_ERROR_INVALID_CALL.");
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
case E_INVALIDARG:
|
case E_INVALIDARG:
|
||||||
{
|
{
|
||||||
Debug::Error("Duplicator::Duplicate() => E_INVALIDARG.");
|
Debug::Error("Duplicator::Duplicate() => E_INVALIDARG.");
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
state_ = State::Unknown;
|
state_ = State::Unknown;
|
||||||
Debug::Error("Duplicator::Duplicate() => Unknown Error.");
|
Debug::Error("Duplicator::Duplicate() => Unknown Error.");
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedReleaser releaser([this]
|
ScopedReleaser releaser([this]
|
||||||
@@ -305,13 +311,15 @@ bool Duplicator::Duplicate(UINT timeout)
|
|||||||
ComPtr<ID3D11Texture2D> texture;
|
ComPtr<ID3D11Texture2D> texture;
|
||||||
if (FAILED(resource.As(&texture)))
|
if (FAILED(resource.As(&texture)))
|
||||||
{
|
{
|
||||||
return false;
|
Debug::Error("Duplicator::Duplicate() => IDXGIResource could not be converted to ID3D11Texture2D.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sharedTexture = device_->GetCompatibleSharedTexture(texture, lastFrameId_ % 2);
|
auto sharedTexture = device_->GetCompatibleSharedTexture(texture, lastFrameId_ % 2);
|
||||||
if (!sharedTexture)
|
if (!sharedTexture)
|
||||||
{
|
{
|
||||||
return false;
|
Debug::Error("Duplicator::Duplicate() => Shared Texture was null.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<ID3D11DeviceContext> context;
|
ComPtr<ID3D11DeviceContext> context;
|
||||||
@@ -331,8 +339,6 @@ bool Duplicator::Duplicate(UINT timeout)
|
|||||||
metaData_
|
metaData_
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ private:
|
|||||||
void InitializeDuplication();
|
void InitializeDuplication();
|
||||||
void CheckUnityAdapter();
|
void CheckUnityAdapter();
|
||||||
|
|
||||||
bool Duplicate(UINT timeout);
|
void Duplicate(UINT timeout);
|
||||||
|
|
||||||
void UpdateCursor(
|
void UpdateCursor(
|
||||||
const Microsoft::WRL::ComPtr<ID3D11Texture2D>& texture,
|
const Microsoft::WRL::ComPtr<ID3D11Texture2D>& texture,
|
||||||
|
|||||||
Reference in New Issue
Block a user