Browse Source

plugins: Ensure that graphics device type checks use graphics context

PatTheMav 2 months ago
parent
commit
8e79dcfc8c

+ 3 - 0
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) {

+ 2 - 2
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,

+ 2 - 1
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;
 }

+ 1 - 1
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;
 }