From 8e79dcfc8cb9c5ac86ba64b370a77bd6e59d9e96 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Sun, 31 Aug 2025 18:51:00 +0200 Subject: [PATCH] plugins: Ensure that graphics device type checks use graphics context --- plugins/mac-avcapture/plugin-main.m | 3 +++ plugins/mac-capture/mac-display-capture.m | 4 ++-- plugins/mac-capture/mac-sck-video-capture.m | 3 ++- plugins/mac-syphon/syphon.m | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/mac-avcapture/plugin-main.m b/plugins/mac-avcapture/plugin-main.m index 81ad4b1f1..a2fd7bf59 100644 --- a/plugins/mac-avcapture/plugin-main.m +++ b/plugins/mac-avcapture/plugin-main.m @@ -35,11 +35,14 @@ static void *av_fast_capture_create(obs_data_t *settings, obs_source_t *source) capture_info->settings = settings; capture_info->source = source; + obs_enter_graphics(); if (gs_get_device_type() == GS_DEVICE_OPENGL) { capture_info->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT_RECT); } else { capture_info->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); } + obs_leave_graphics(); + capture_info->frameSize = CGRectZero; if (!capture_info->effect) { diff --git a/plugins/mac-capture/mac-display-capture.m b/plugins/mac-capture/mac-display-capture.m index ef346031d..a6c7b6211 100644 --- a/plugins/mac-capture/mac-display-capture.m +++ b/plugins/mac-capture/mac-display-capture.m @@ -255,6 +255,8 @@ static void *display_capture_create(obs_data_t *settings, obs_source_t *source) dc->source = source; dc->hide_cursor = !obs_data_get_bool(settings, "show_cursor"); + obs_enter_graphics(); + if (gs_get_device_type() == GS_DEVICE_OPENGL) { dc->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT_RECT); } else { @@ -264,8 +266,6 @@ static void *display_capture_create(obs_data_t *settings, obs_source_t *source) if (!dc->effect) goto fail; - obs_enter_graphics(); - struct gs_sampler_info info = { .filter = GS_FILTER_LINEAR, .address_u = GS_ADDRESS_CLAMP, diff --git a/plugins/mac-capture/mac-sck-video-capture.m b/plugins/mac-capture/mac-sck-video-capture.m index e59804f9e..258dd34fe 100644 --- a/plugins/mac-capture/mac-sck-video-capture.m +++ b/plugins/mac-capture/mac-sck-video-capture.m @@ -291,11 +291,13 @@ API_AVAILABLE(macos(12.5)) static void *sck_video_capture_create(obs_data_t *set sc->capture_delegate = [[ScreenCaptureDelegate alloc] init]; sc->capture_delegate.sc = sc; + obs_enter_graphics(); if (gs_get_device_type() == GS_DEVICE_OPENGL) { sc->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT_RECT); } else { sc->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); } + obs_leave_graphics(); if (!sc->effect) goto fail; @@ -311,7 +313,6 @@ API_AVAILABLE(macos(12.5)) static void *sck_video_capture_create(obs_data_t *set return sc; fail: - obs_leave_graphics(); sck_video_capture_destroy(sc); return NULL; } diff --git a/plugins/mac-syphon/syphon.m b/plugins/mac-syphon/syphon.m index 1f96cf164..cb83421a0 100644 --- a/plugins/mac-syphon/syphon.m +++ b/plugins/mac-syphon/syphon.m @@ -312,13 +312,13 @@ static inline bool init_obs_graphics_objects(syphon_t s) obs_enter_graphics(); s->sampler = gs_samplerstate_create(&info); s->vertbuffer = create_vertbuffer(); - obs_leave_graphics(); if (gs_get_device_type() == GS_DEVICE_OPENGL) { s->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT_RECT); } else { s->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); } + obs_leave_graphics(); return s->sampler != NULL && s->vertbuffer != NULL && s->effect != NULL; }