mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-31 02:13:51 +08:00
plugins: Ensure that graphics device type checks use graphics context
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user