mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
refactor: 简化与Runtime交互的逻辑
This commit is contained in:
parent
e727dabbfa
commit
813e4ee93b
12 changed files with 218 additions and 174 deletions
|
|
@ -34,12 +34,12 @@ bool GraphicsCaptureFrameSource::Initialize() {
|
|||
|
||||
if (!winrt::ApiInformation::IsTypePresent(L"Windows.Graphics.Capture.GraphicsCaptureSession")) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "不存在 GraphicsCaptureSession API");
|
||||
App::SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
App::GetInstance().SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
return false;
|
||||
}
|
||||
if (!winrt::GraphicsCaptureSession::IsSupported()) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "当前不支持 WinRT 捕获");
|
||||
App::SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
App::GetInstance().SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ bool GraphicsCaptureFrameSource::Initialize() {
|
|||
);
|
||||
if (FAILED(hr)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("创建 IDirect3DDevice 失败", hr));
|
||||
App::SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
App::GetInstance().SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ bool GraphicsCaptureFrameSource::Initialize() {
|
|||
auto interop = winrt::get_activation_factory<winrt::GraphicsCaptureItem, IGraphicsCaptureItemInterop>();
|
||||
if (!interop) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "获取 IGraphicsCaptureItemInterop 失败");
|
||||
App::SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
App::GetInstance().SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ bool GraphicsCaptureFrameSource::Initialize() {
|
|||
);
|
||||
if (FAILED(hr)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("创建 GraphicsCaptureItem 失败", hr));
|
||||
App::SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
App::GetInstance().SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ bool GraphicsCaptureFrameSource::Initialize() {
|
|||
_captureSession.StartCapture();
|
||||
} catch (const winrt::hresult_error& e) {
|
||||
SPDLOG_LOGGER_ERROR(logger, fmt::format("初始化 WinRT 失败:{}", Utils::UTF16ToUTF8(e.message())));
|
||||
App::SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
App::GetInstance().SetErrorMsg(ErrorMessages::GRAPHICS_CAPTURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue