Browse Source

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.
PatTheMav 1 year ago
parent
commit
bf00c17b2b
3 changed files with 10 additions and 7 deletions
  1. 7 3
      UI/window-basic-main-profiles.cpp
  2. 2 4
      UI/window-basic-main.cpp
  3. 1 0
      UI/window-basic-main.hpp

+ 7 - 3
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();

+ 2 - 4
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();
 

+ 1 - 0
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<std::string> GetRestartRequirements(const ConfigFile &config) const;
 	void ResetProfileData();
 	void CheckForSimpleModeX264Fallback();