Skip to content

Commit cb85c1d

Browse files
committed
Disable filter for scenes and groups
1 parent 3b6f257 commit cb85c1d

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/source-defaults-filter.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct sceneitem_find_data {
117117
/* Forward declarations */
118118
static void source_defaults_frontend_event_cb(enum obs_frontend_event event,
119119
void *data);
120+
static void source_defaults_enable(void *data, calldata_t *cd);
120121

121122
/************************/
122123

@@ -465,6 +466,16 @@ static void source_created_cb(void *data, calldata_t *cd)
465466
blog(LOG_WARNING,
466467
"Filter has no parent source, so new source was skipped.");
467468
return;
469+
} else if (obs_source_get_output_flags(parent_source) &
470+
OBS_SOURCE_COMPOSITE) {
471+
signal_handler_t *sh = obs_get_signal_handler();
472+
signal_handler_disconnect(sh, "source_create",
473+
source_created_cb, src);
474+
sh = obs_source_get_signal_handler(src->source);
475+
signal_handler_disconnect(sh, "enable", source_defaults_enable,
476+
src);
477+
obs_enum_scenes(all_scenes_item_add_disconnect, src);
478+
return;
468479
}
469480

470481
// should be same type
@@ -621,6 +632,23 @@ static obs_properties_t *source_defaults_properties(void *data)
621632
{
622633
struct source_defaults *src = data;
623634
obs_properties_t *props = obs_properties_create();
635+
obs_source_t *parent_source = obs_filter_get_parent(src->source);
636+
obs_weak_source_release(src->parent_source_weak);
637+
src->parent_source_weak = obs_source_get_weak_source(parent_source);
638+
if (obs_source_get_output_flags(parent_source) & OBS_SOURCE_COMPOSITE) {
639+
obs_properties_add_text(
640+
props, "description",
641+
"This filter can not be applied on scenes and groups",
642+
OBS_TEXT_INFO);
643+
signal_handler_t *sh = obs_get_signal_handler();
644+
signal_handler_disconnect(sh, "source_create",
645+
source_created_cb, src);
646+
sh = obs_source_get_signal_handler(src->source);
647+
signal_handler_disconnect(sh, "enable", source_defaults_enable,
648+
src);
649+
obs_enum_scenes(all_scenes_item_add_disconnect, src);
650+
return props;
651+
}
624652
obs_properties_t *sceneitem_settings_group = obs_properties_create();
625653

626654
obs_properties_add_text(
@@ -633,9 +661,6 @@ static obs_properties_t *source_defaults_properties(void *data)
633661
option_labels[i]);
634662
}
635663

636-
obs_source_t *parent_source = obs_filter_get_parent(src->source);
637-
obs_weak_source_release(src->parent_source_weak);
638-
src->parent_source_weak = obs_source_get_weak_source(parent_source);
639664
if (obs_source_get_output_flags(parent_source) & OBS_SOURCE_AUDIO) {
640665
for (size_t i = 2; i < OBS_COUNTOF(option_keys); i++) {
641666
obs_properties_add_bool(props, option_keys[i],

0 commit comments

Comments
 (0)