From 6209bea37125e350a4172ead72395baee8d32f27 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 14 Mar 2020 10:40:42 -0700 Subject: [PATCH] win-capture: Destroy winrt in graphics thread --- plugins/win-capture/window-capture.c | 35 +++++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/plugins/win-capture/window-capture.c b/plugins/win-capture/window-capture.c index e23601efb..1943ce3bf 100644 --- a/plugins/win-capture/window-capture.c +++ b/plugins/win-capture/window-capture.c @@ -210,24 +210,31 @@ static void *wc_create(obs_data_t *settings, obs_source_t *source) return wc; } -static void wc_destroy(void *data) +static void wc_actual_destroy(void *data) { struct window_capture *wc = data; - if (wc) { - obs_enter_graphics(); - dc_capture_free(&wc->capture); - obs_leave_graphics(); - - bfree(wc->title); - bfree(wc->class); - bfree(wc->executable); - - if (wc->winrt_module) - os_dlclose(wc->winrt_module); - - bfree(wc); + if (wc->capture_winrt) { + wc->exports.winrt_capture_free(wc->capture_winrt); } + + obs_enter_graphics(); + dc_capture_free(&wc->capture); + obs_leave_graphics(); + + bfree(wc->title); + bfree(wc->class); + bfree(wc->executable); + + if (wc->winrt_module) + os_dlclose(wc->winrt_module); + + bfree(wc); +} + +static void wc_destroy(void *data) +{ + obs_queue_task(OBS_TASK_GRAPHICS, wc_actual_destroy, data, false); } static void wc_update(void *data, obs_data_t *settings)