Skip to content

Commit

Permalink
UI: Update profile encoder information after module load
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PatTheMav authored and RytoEX committed Oct 30, 2024
1 parent 0be9d9f commit bf00c17
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 7 additions & 3 deletions UI/window-basic-main-profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -731,6 +729,12 @@ void OBSBasic::ActivateProfile(const OBSProfile &profile, bool reset)
}
}

void OBSBasic::UpdateProfileEncoders()
{
InitBasicConfigDefaults2();
CheckForSimpleModeX264Fallback();
}

void OBSBasic::ResetProfileData()
{
ResetVideo();
Expand Down
6 changes: 2 additions & 4 deletions UI/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ bool OBSBasic::InitBasicConfig()
return false;
}

return InitBasicConfigDefaults();
return true;
}

void OBSBasic::InitOBSCallbacks()
Expand Down Expand Up @@ -2123,9 +2123,7 @@ void OBSBasic::OBSInit()
emit VirtualCamEnabled();
}

InitBasicConfigDefaults2();

CheckForSimpleModeX264Fallback();
UpdateProfileEncoders();

LogEncoders();

Expand Down
1 change: 1 addition & 0 deletions UI/window-basic-main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,7 @@ public slots:
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();
Expand Down

0 comments on commit bf00c17

Please sign in to comment.