win-capture: Fix potential crash due to unhandled exceptions
This commit is contained in:
@@ -29,7 +29,8 @@ struct winrt_exports {
|
||||
BOOL *(*winrt_capture_supported)();
|
||||
BOOL *(*winrt_capture_cursor_toggle_supported)();
|
||||
struct winrt_capture *(*winrt_capture_init)(BOOL cursor, HWND window,
|
||||
BOOL client_area);
|
||||
BOOL client_area,
|
||||
char **error, HRESULT *hr);
|
||||
void (*winrt_capture_free)(struct winrt_capture *capture);
|
||||
void (*winrt_capture_show_cursor)(struct winrt_capture *capture,
|
||||
BOOL visible);
|
||||
@@ -61,6 +62,7 @@ struct window_capture {
|
||||
struct dc_capture capture;
|
||||
|
||||
bool wgc_supported;
|
||||
bool previously_failed;
|
||||
void *winrt_module;
|
||||
struct winrt_exports exports;
|
||||
struct winrt_capture *capture_winrt;
|
||||
@@ -478,8 +480,24 @@ static void wc_tick(void *data, float seconds)
|
||||
dc_capture_capture(&wc->capture, wc->window);
|
||||
} else if (wc->method == METHOD_WGC) {
|
||||
if (wc->window && (wc->capture_winrt == NULL)) {
|
||||
char *error = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
wc->capture_winrt = wc->exports.winrt_capture_init(
|
||||
wc->cursor, wc->window, wc->client_area);
|
||||
wc->cursor, wc->window, wc->client_area, &error,
|
||||
&hr);
|
||||
|
||||
if (!wc->capture_winrt && !wc->previously_failed) {
|
||||
blog(LOG_WARNING,
|
||||
"%s: winrt_capture_init failed: %s: %lX",
|
||||
obs_source_get_name(wc->source), error,
|
||||
hr);
|
||||
wc->previously_failed = true;
|
||||
} else if (wc->capture_winrt) {
|
||||
wc->previously_failed = false;
|
||||
}
|
||||
|
||||
bfree(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user