UI: Fix bug with advanced output service settings
When the user had advanced output mode selected and they created a new profile, enforced service settings for advanced output mode would not be applied because GetDataFromJsonFile would return a nullptr (because the settings file did not yet exist). Instead of returning nullptr, always return a valid data object, and in addition, apply the defaults of the encoder to pass to obs_service_apply_encoder_settings just to be safe.
This commit is contained in:
parent
621c519cc5
commit
310c98e641
@ -1033,19 +1033,32 @@ struct AdvancedOutput : BasicOutputHandler {
|
||||
static OBSData GetDataFromJsonFile(const char *jsonFile)
|
||||
{
|
||||
char fullPath[512];
|
||||
obs_data_t *data = nullptr;
|
||||
|
||||
int ret = GetProfilePath(fullPath, sizeof(fullPath), jsonFile);
|
||||
if (ret > 0) {
|
||||
BPtr<char> jsonData = os_quick_read_utf8_file(fullPath);
|
||||
if (!!jsonData) {
|
||||
obs_data_t *data = obs_data_create_from_json(jsonData);
|
||||
OBSData dataRet(data);
|
||||
obs_data_release(data);
|
||||
return dataRet;
|
||||
data = obs_data_create_from_json(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
if (!data)
|
||||
data = obs_data_create();
|
||||
OBSData dataRet(data);
|
||||
obs_data_release(data);
|
||||
return dataRet;
|
||||
}
|
||||
|
||||
static void ApplyEncoderDefaults(OBSData &settings,
|
||||
const obs_encoder_t *encoder)
|
||||
{
|
||||
OBSData dataRet = obs_encoder_get_defaults(encoder);
|
||||
obs_data_release(dataRet);
|
||||
|
||||
if (!!settings)
|
||||
obs_data_apply(dataRet, settings);
|
||||
settings = std::move(dataRet);
|
||||
}
|
||||
|
||||
AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
||||
@ -1158,6 +1171,7 @@ void AdvancedOutput::UpdateStreamSettings()
|
||||
"ApplyServiceSettings");
|
||||
|
||||
OBSData settings = GetDataFromJsonFile("streamEncoder.json");
|
||||
ApplyEncoderDefaults(settings, h264Streaming);
|
||||
|
||||
if (applyServiceSettings)
|
||||
obs_service_apply_encoder_settings(main->GetService(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user