From 55e246a208de3b6b7378abf0db4e07f25e2aa22a Mon Sep 17 00:00:00 2001 From: wangshaohui <97082645@qq.com> Date: Tue, 31 Dec 2024 23:23:16 +0800 Subject: [PATCH 1/2] obs-frontend-api: Add event for video reset For 3rd plugins, they should re-create the obs_output or video_output hold in their code. Otherwise, 3rd plugins will easily crash after calling obs_reset_video in OBS. --- UI/obs-frontend-api/obs-frontend-api.h | 1 + UI/window-basic-main.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/UI/obs-frontend-api/obs-frontend-api.h b/UI/obs-frontend-api/obs-frontend-api.h index 4b409e337723bd..94106c53d1c21f 100644 --- a/UI/obs-frontend-api/obs-frontend-api.h +++ b/UI/obs-frontend-api/obs-frontend-api.h @@ -62,6 +62,7 @@ enum obs_frontend_event { OBS_FRONTEND_EVENT_SCENE_COLLECTION_RENAMED, OBS_FRONTEND_EVENT_THEME_CHANGED, OBS_FRONTEND_EVENT_SCREENSHOT_TAKEN, + OBS_FRONTEND_EVENT_VIDEO_RESET, }; /* ------------------------------------------------------------------------- */ diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 47cac8dccfe7cc..4bfb879ac22b40 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -4516,6 +4516,8 @@ int OBSBasic::ResetVideo() migrationBaseResolution->second != ovi.base_height)); ui->actionRemigrateSceneCollection->setEnabled(canMigrate); + OnEvent(OBS_FRONTEND_EVENT_VIDEO_RESET); + emit CanvasResized(ovi.base_width, ovi.base_height); emit OutputResized(ovi.output_width, ovi.output_height); } From 3750683ba148519d581d676c759ef7600fd62e20 Mon Sep 17 00:00:00 2001 From: wangshaohui <97082645@qq.com> Date: Tue, 31 Dec 2024 23:23:16 +0800 Subject: [PATCH 2/2] libobs: Add signals for video reset For 3rd plugins, they should re-create the obs_output or video_output hold in their code. Otherwise, 3rd plugins will easily crash after calling obs_reset_video in OBS. --- libobs/obs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libobs/obs.c b/libobs/obs.c index 845c9d49b7e6c1..439583109a29c2 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -30,6 +30,12 @@ static THREAD_LOCAL bool is_ui_thread = false; extern void add_default_module_paths(void); extern char *find_libobs_data_file(const char *file); +static inline void obs_video_dosignal(const char *signal_obs) +{ + struct calldata params = {0}; + signal_handler_signal(obs->signals, signal_obs, ¶ms); +} + static inline void make_video_info(struct video_output_info *vi, struct obs_video_info *ovi) { vi->name = "video"; @@ -695,6 +701,7 @@ static int obs_init_video(struct obs_video_info *ovi) video->thread_initialized = true; + obs_video_dosignal("core_video_ready"); return OBS_VIDEO_SUCCESS; } @@ -820,6 +827,8 @@ static void obs_free_video(void) pthread_mutex_destroy(&obs->video.task_mutex); pthread_mutex_init_value(&obs->video.task_mutex); deque_free(&obs->video.tasks); + + obs_video_dosignal("core_video_released"); } static void obs_free_graphics(void) @@ -1053,6 +1062,9 @@ static const char *obs_signals[] = { "void hotkey_unregister(ptr hotkey)", "void hotkey_bindings_changed(ptr hotkey)", + "void core_video_ready()", + "void core_video_released()", + NULL, };