From a1e0626c14c832c4fff8939691e2b5021e1d362b Mon Sep 17 00:00:00 2001 From: gxalpha Date: Sat, 25 May 2024 13:40:36 +0200 Subject: [PATCH] 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. --- docs/sphinx/reference-core.rst | 8 ++++++++ libobs/obs-source.c | 2 ++ libobs/obs.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/docs/sphinx/reference-core.rst b/docs/sphinx/reference-core.rst index 3e55dc94e..ba986cfc0 100644 --- a/docs/sphinx/reference-core.rst +++ b/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. diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 01abb87d0..28182d813 100644 --- a/libobs/obs-source.c +++ b/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'", diff --git a/libobs/obs.c b/libobs/obs.c index f3713396e..ea930cc67 100644 --- a/libobs/obs.c +++ b/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, "