d3d12screencapturesrc: Fix OS handle leaks/random crash in WGC mode

Multiple DispatcherQueues per thread seems to be causing OS handle leak
and random crashes were observed. Instead of creating
thread/DispatcherQueue per GstD3D12GraphicsCapture object,
reuse only single thread and DispatcherQueue

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4351
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9153>
This commit is contained in:
Seungha Yang 2025-06-01 00:02:16 +09:00 committed by GStreamer Marge Bot
parent c15a898742
commit e3d0a8d83e
3 changed files with 496 additions and 369 deletions

View File

@ -30,6 +30,8 @@ G_DECLARE_FINAL_TYPE (GstD3D12GraphicsCapture, gst_d3d12_graphics_capture,
gboolean gst_d3d12_graphics_capture_load_library (void);
void gst_d3d12_graphics_capture_deinit (void);
GstD3D12ScreenCapture * gst_d3d12_graphics_capture_new (GstD3D12Device * device,
HWND window_handle,
HMONITOR monitor_handle);

View File

@ -67,6 +67,10 @@
#include "gstd3d12upload.h"
#endif
#ifdef HAVE_WGC
#include "gstd3d12graphicscapture.h"
#endif
/* *INDENT-OFF* */
using namespace Microsoft::WRL;
/* *INDENT-ON* */
@ -74,6 +78,9 @@ using namespace Microsoft::WRL;
static void
plugin_deinit (gpointer data)
{
#ifdef HAVE_WGC
gst_d3d12_graphics_capture_deinit ();
#endif
gst_d3d12_ipc_client_deinit ();
gst_d3d12_flush_all_devices ();
}