diff options
author | Timo Rothenpieler <[email protected]> | 2025-09-17 19:13:29 +0200 |
---|---|---|
committer | Timo Rothenpieler <[email protected]> | 2025-09-18 01:04:59 +0000 |
commit | 4879c9f4e2f2afc269d305d941cf70d18f3883a8 (patch) | |
tree | dad09fabfff4b16fdf878c6f86aa88c6aa373fe7 /libavfilter/vsrc_gfxcapture_winrt.cpp | |
parent | 23d9412ff9598b8989072e53d5474a41d2f14042 (diff) |
avfilter/vsrc_gfxcapture: stop capture session before initializing capture thread shutdown
It might have things going on in the background that still need cleaned
up, and this gives it a chance to enqueue them on the dispatch queue.
Diffstat (limited to 'libavfilter/vsrc_gfxcapture_winrt.cpp')
-rw-r--r-- | libavfilter/vsrc_gfxcapture_winrt.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libavfilter/vsrc_gfxcapture_winrt.cpp b/libavfilter/vsrc_gfxcapture_winrt.cpp index ade14d297f..47c3b2db88 100644 --- a/libavfilter/vsrc_gfxcapture_winrt.cpp +++ b/libavfilter/vsrc_gfxcapture_winrt.cpp @@ -229,7 +229,7 @@ static void wgc_stop_capture_session(AVFilterContext *avctx) noexcept if (wgctx->capture_session) { ComPtr<IClosable> closable; if (SUCCEEDED(wgctx->capture_session.As(&closable))) { - closable->Close(); + CHECK_HR_LOG(closable->Close()); } else { av_log(avctx, AV_LOG_ERROR, "Failed to get capture session IClosable interface\n"); } @@ -243,6 +243,11 @@ static void wgc_stop_capture_session(AVFilterContext *avctx) noexcept av_log(avctx, AV_LOG_ERROR, "Failed to get frame pool IClosable interface\n"); } } + + wgctx->capture_session.Reset(); + wgctx->frame_pool.Reset(); + wgctx->capture_item.Reset(); + wgctx->d3d_device.Reset(); } static int wgc_calculate_client_area(AVFilterContext *avctx) @@ -557,6 +562,9 @@ static int wgc_thread_worker(AVFilterContext *avctx) if (!msg.hwnd && msg.message == WM_WGC_THREAD_SHUTDOWN) { av_log(avctx, AV_LOG_DEBUG, "Initializing WGC thread shutdown\n"); + + wgc_stop_capture_session(avctx); + if (FAILED(wgctx->dispatcher_queue_controller->ShutdownQueueAsync(&async))) { av_log(avctx, AV_LOG_ERROR, "Failed to shutdown dispatcher queue\n"); return AVERROR_EXTERNAL; |