Просмотр исходного кода

libobs: Add global source filter add/remove signals

Adds global signals for when a filter is added to or removed from a
source. These will be helpful for listening for changes to a sources
filters without having to attach and detach a signal handler, which
would be annoying in the context of for example context menus which
change sources rapidly.
gxalpha 1 год назад
Родитель
Сommit
a1e0626c14
3 измененных файлов с 12 добавлено и 0 удалено
  1. 8 0
      docs/sphinx/reference-core.rst
  2. 2 0
      libobs/obs-source.c
  3. 2 0
      libobs/obs.c

+ 8 - 0
docs/sphinx/reference-core.rst

@@ -702,6 +702,14 @@ Core OBS Signals
 
    Called when a source's audio becomes inactive.
 
+**source_filter_add** (ptr source, ptr filter)
+
+   Called when a filter is added to a source.
+
+**source_filter_remove** (ptr source, ptr filter)
+
+   Called when a filter is removed from a source.
+
 **source_transition_start** (ptr source)
 
    Called when a transition has started its transition.

+ 2 - 0
libobs/obs-source.c

@@ -3218,6 +3218,7 @@ void obs_source_filter_add(obs_source_t *source, obs_source_t *filter)
 	calldata_set_ptr(&cd, "source", source);
 	calldata_set_ptr(&cd, "filter", filter);
 
+	signal_handler_signal(obs->signals, "source_filter_add", &cd);
 	signal_handler_signal(source->context.signals, "filter_add", &cd);
 
 	blog(LOG_DEBUG, "- filter '%s' (%s) added to source '%s'",
@@ -3256,6 +3257,7 @@ static bool obs_source_filter_remove_refless(obs_source_t *source,
 	calldata_set_ptr(&cd, "source", source);
 	calldata_set_ptr(&cd, "filter", filter);
 
+	signal_handler_signal(obs->signals, "source_filter_remove", &cd);
 	signal_handler_signal(source->context.signals, "filter_remove", &cd);
 
 	blog(LOG_DEBUG, "- filter '%s' (%s) removed from source '%s'",

+ 2 - 0
libobs/obs.c

@@ -1117,6 +1117,8 @@ static const char *obs_signals[] = {
 	"void source_hide(ptr source)",
 	"void source_audio_activate(ptr source)",
 	"void source_audio_deactivate(ptr source)",
+	"void source_filter_add(ptr source, ptr filter)",
+	"void source_filter_remove(ptr source, ptr filter)",
 	"void source_rename(ptr source, string new_name, string prev_name)",
 	"void source_volume(ptr source, in out float volume)",
 	"void source_volume_level(ptr source, float level, float magnitude, "