Merge pull request #1960 from Xaymar/patch-get_defaults2

libobs: Call both get_defaults and get_defaults2
master
Colin Edwards 2019-07-13 20:40:20 -05:00 committed by GitHub
commit c64d82530d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 6 deletions

View File

@ -66,8 +66,12 @@ static bool init_encoder(struct obs_encoder *encoder, const char *name,
if (pthread_mutex_init(&encoder->pause.mutex, NULL) != 0)
return false;
if (encoder->orig_info.get_defaults)
if (encoder->orig_info.get_defaults) {
encoder->orig_info.get_defaults(encoder->context.settings);
}
if (encoder->orig_info.get_defaults2) {
encoder->orig_info.get_defaults2(encoder->context.settings, encoder->orig_info.type_data);
}
return true;
}
@ -316,10 +320,11 @@ void obs_encoder_set_name(obs_encoder_t *encoder, const char *name)
static inline obs_data_t *get_defaults(const struct obs_encoder_info *info)
{
obs_data_t *settings = obs_data_create();
if (info->get_defaults) {
info->get_defaults(settings);
}
if (info->get_defaults2) {
info->get_defaults2(settings, info->type_data);
} else if (info->get_defaults) {
info->get_defaults(settings);
}
return settings;
}

View File

@ -238,6 +238,9 @@ struct obs_encoder_info {
/**
* Gets the default settings for this encoder
*
* If get_defaults is also defined both will be called, and the first
* call will be to get_defaults, then to get_defaults2.
*
* @param[out] settings Data to assign default settings to
* @param[in] typedata Type Data

View File

@ -324,11 +324,13 @@ static obs_source_t *obs_source_create_internal(const char *id,
goto fail;
if (info) {
if (info->get_defaults2)
if (info->get_defaults) {
info->get_defaults(source->context.settings);
}
if (info->get_defaults2) {
info->get_defaults2(info->type_data,
source->context.settings);
else if (info->get_defaults)
info->get_defaults(source->context.settings);
}
}
if (!obs_source_init(source))

View File

@ -441,6 +441,9 @@ struct obs_source_info {
/**
* Gets the default settings for this source
*
* If get_defaults is also defined both will be called, and the first
* call will be to get_defaults, then to get_defaults2.
*
* @param type_data The type_data variable of this structure
* @param[out] settings Data to assign default settings to