Skip to content

Commit

Permalink
libobs-winrt: Make Close() failures non-fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
jpark37 authored and jp9000 committed Feb 15, 2021
1 parent 17cb0ac commit 744cb97
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions libobs-winrt/winrt-capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,27 @@ static void winrt_capture_device_loss_release(void *data)
capture->active = FALSE;

capture->frame_arrived.revoke();
capture->frame_pool.Close();
capture->session.Close();

try {
capture->frame_pool.Close();
} catch (winrt::hresult_error &err) {
blog(LOG_ERROR,
"Direct3D11CaptureFramePool::Close (0x%08X): %ls",
err.to_abi(), err.message().c_str());
} catch (...) {
blog(LOG_ERROR, "Direct3D11CaptureFramePool::Close (0x%08X)",
winrt::to_hresult());
}

try {
capture->session.Close();
} catch (winrt::hresult_error &err) {
blog(LOG_ERROR, "GraphicsCaptureSession::Close (0x%08X): %ls",
err.to_abi(), err.message().c_str());
} catch (...) {
blog(LOG_ERROR, "GraphicsCaptureSession::Close (0x%08X)",
winrt::to_hresult());
}

capture->session = nullptr;
capture->frame_pool = nullptr;
Expand Down Expand Up @@ -516,8 +535,30 @@ extern "C" EXPORT void winrt_capture_free(struct winrt_capture *capture)

capture->frame_arrived.revoke();
capture->closed.revoke();
capture->frame_pool.Close();
capture->session.Close();

try {
capture->frame_pool.Close();
} catch (winrt::hresult_error &err) {
blog(LOG_ERROR,
"Direct3D11CaptureFramePool::Close (0x%08X): %ls",
err.to_abi(), err.message().c_str());
} catch (...) {
blog(LOG_ERROR,
"Direct3D11CaptureFramePool::Close (0x%08X)",
winrt::to_hresult());
}

try {
capture->session.Close();
} catch (winrt::hresult_error &err) {
blog(LOG_ERROR,
"GraphicsCaptureSession::Close (0x%08X): %ls",
err.to_abi(), err.message().c_str());
} catch (...) {
blog(LOG_ERROR,
"GraphicsCaptureSession::Close (0x%08X)",
winrt::to_hresult());
}

delete capture;
}
Expand Down

0 comments on commit 744cb97

Please sign in to comment.