From bf00c17b2b533efa5b55763da144a2914886951f Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Tue, 29 Oct 2024 16:10:27 +0100 Subject: [PATCH] UI: Update profile encoder information after module load The function InitBasicConfigDefaults2's purpose is to set up encoder- related settings for a profile, which requires all available encoders to have been discovered first. As encoders are added by runtime modules, this also means that discovery needs to be delayed until after modules have been loaded, but modules themselves require a valid profile to exist and be loaded. This leads to the requirement of profiles needing to exist in a half-initialized state when modules are loaded and only becoming fully initialized after that. This distinction is not necessary after the initial launch of obs-studio because runtime plugins are not hot-loadable, so the update can happen unconditionally at any time a plugin is changed, which implicitly couples every call to ActivateProfile with a call to UpdateProfileEncoders. --- UI/window-basic-main-profiles.cpp | 10 +++++++--- UI/window-basic-main.cpp | 6 ++---- UI/window-basic-main.hpp | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/UI/window-basic-main-profiles.cpp b/UI/window-basic-main-profiles.cpp index 57e2d8b31..12f8a0cbe 100644 --- a/UI/window-basic-main-profiles.cpp +++ b/UI/window-basic-main-profiles.cpp @@ -699,14 +699,12 @@ void OBSBasic::ActivateProfile(const OBSProfile &profile, bool reset) config_save_safe(App()->GetUserConfig(), "tmp", nullptr); InitBasicConfigDefaults(); - InitBasicConfigDefaults2(); if (reset) { + UpdateProfileEncoders(); ResetProfileData(); } - CheckForSimpleModeX264Fallback(); - RefreshProfiles(); UpdateTitleBar(); @@ -731,6 +729,12 @@ void OBSBasic::ActivateProfile(const OBSProfile &profile, bool reset) } } +void OBSBasic::UpdateProfileEncoders() +{ + InitBasicConfigDefaults2(); + CheckForSimpleModeX264Fallback(); +} + void OBSBasic::ResetProfileData() { ResetVideo(); diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index ca9ec5fdf..bbc3e6cb3 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -1898,7 +1898,7 @@ bool OBSBasic::InitBasicConfig() return false; } - return InitBasicConfigDefaults(); + return true; } void OBSBasic::InitOBSCallbacks() @@ -2123,9 +2123,7 @@ void OBSBasic::OBSInit() emit VirtualCamEnabled(); } - InitBasicConfigDefaults2(); - - CheckForSimpleModeX264Fallback(); + UpdateProfileEncoders(); LogEncoders(); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index d04edfeff..81bb7b478 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -1301,6 +1301,7 @@ private: void RefreshProfiles(bool refreshCache = false); void ActivateProfile(const OBSProfile &profile, bool reset = false); + void UpdateProfileEncoders(); std::vector GetRestartRequirements(const ConfigFile &config) const; void ResetProfileData(); void CheckForSimpleModeX264Fallback();