提交 5d7c899e 编写于 作者: J jp9000

libobs: Add obs_source_info::get_defaults2

Uses type_data to get the type-specific data of a source type
上级 7f6cf97b
...@@ -323,8 +323,13 @@ static obs_source_t *obs_source_create_internal(const char *id, ...@@ -323,8 +323,13 @@ static obs_source_t *obs_source_create_internal(const char *id,
private)) private))
goto fail; goto fail;
if (info && info->get_defaults) if (info) {
if (info->get_defaults2)
info->get_defaults2(info->type_data,
source->context.settings);
else if (info->get_defaults)
info->get_defaults(source->context.settings); info->get_defaults(source->context.settings);
}
if (!obs_source_init(source)) if (!obs_source_init(source))
goto fail; goto fail;
...@@ -695,7 +700,9 @@ bool obs_source_removed(const obs_source_t *source) ...@@ -695,7 +700,9 @@ bool obs_source_removed(const obs_source_t *source)
static inline obs_data_t *get_defaults(const struct obs_source_info *info) static inline obs_data_t *get_defaults(const struct obs_source_info *info)
{ {
obs_data_t *settings = obs_data_create(); obs_data_t *settings = obs_data_create();
if (info->get_defaults) if (info->get_defaults2)
info->get_defaults2(info->type_data, settings);
else if (info->get_defaults)
info->get_defaults(settings); info->get_defaults(settings);
return settings; return settings;
} }
......
...@@ -201,6 +201,7 @@ struct obs_source_info { ...@@ -201,6 +201,7 @@ struct obs_source_info {
* Gets the default settings for this source * Gets the default settings for this source
* *
* @param[out] settings Data to assign default settings to * @param[out] settings Data to assign default settings to
* @deprecated Use get_defaults2 if type_data is needed
*/ */
void (*get_defaults)(obs_data_t *settings); void (*get_defaults)(obs_data_t *settings);
...@@ -428,6 +429,14 @@ struct obs_source_info { ...@@ -428,6 +429,14 @@ struct obs_source_info {
void (*transition_start)(void *data); void (*transition_start)(void *data);
void (*transition_stop)(void *data); void (*transition_stop)(void *data);
/**
* Gets the default settings for this source
*
* @param type_data The type_data variable of this structure
* @param[out] settings Data to assign default settings to
*/
void (*get_defaults2)(void *type_data, obs_data_t *settings);
}; };
EXPORT void obs_register_source_s(const struct obs_source_info *info, EXPORT void obs_register_source_s(const struct obs_source_info *info,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册