libobs: Add ability to disable source types
Because it would be troublesome to add the ability to remove source types (in case for example a script fails to reload), instead make it so source types can be temporarily disabled while the program is running.
This commit is contained in:
parent
c8a0f661fb
commit
a730f9d6ce
@ -691,7 +691,7 @@ struct obs_source {
|
||||
obs_data_t *private_settings;
|
||||
};
|
||||
|
||||
extern const struct obs_source_info *get_source_info(const char *id);
|
||||
extern struct obs_source_info *get_source_info(const char *id);
|
||||
extern bool obs_source_init_context(struct obs_source *source,
|
||||
obs_data_t *settings, const char *name,
|
||||
obs_data_t *hotkey_data, bool private);
|
||||
|
@ -39,7 +39,7 @@ static inline bool deinterlacing_enabled(const struct obs_source *source)
|
||||
return source->deinterlace_mode != OBS_DEINTERLACE_MODE_DISABLE;
|
||||
}
|
||||
|
||||
const struct obs_source_info *get_source_info(const char *id)
|
||||
struct obs_source_info *get_source_info(const char *id)
|
||||
{
|
||||
for (size_t i = 0; i < obs->source_types.num; i++) {
|
||||
struct obs_source_info *info = &obs->source_types.array[i];
|
||||
@ -4115,3 +4115,16 @@ bool obs_source_async_decoupled(const obs_source_t *source)
|
||||
return obs_source_valid(source, "obs_source_async_decoupled") ?
|
||||
source->async_decoupled : false;
|
||||
}
|
||||
|
||||
/* hidden/undocumented export to allow source type redefinition for scripts */
|
||||
EXPORT void obs_enable_source_type(const char *name, bool enable)
|
||||
{
|
||||
struct obs_source_info *info = get_source_info(name);
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
if (enable)
|
||||
info->output_flags &= ~OBS_SOURCE_CAP_DISABLED;
|
||||
else
|
||||
info->output_flags |= OBS_SOURCE_CAP_DISABLED;
|
||||
}
|
||||
|
@ -130,6 +130,11 @@ enum obs_source_type {
|
||||
*/
|
||||
#define OBS_SOURCE_DO_NOT_SELF_MONITOR (1<<9)
|
||||
|
||||
/**
|
||||
* Source type is currently disabled and should not be shown to the user
|
||||
*/
|
||||
#define OBS_SOURCE_CAP_DISABLED (1<<10)
|
||||
|
||||
/** @} */
|
||||
|
||||
typedef void (*obs_source_enum_proc_t)(obs_source_t *parent,
|
||||
|
Loading…
x
Reference in New Issue
Block a user