Bläddra i källkod

libobs: Add filter_remove callback for sources

Adds a source callback function that is used when a filter is removed
from a source.  This ensures that any data that might be associated with
that source can be cleaned up if necessary.
jp9000 10 år sedan
förälder
incheckning
7878fda442
2 ändrade filer med 12 tillägg och 0 borttagningar
  1. 4 0
      libobs/obs-source.c
  2. 8 0
      libobs/obs-source.h

+ 4 - 0
libobs/obs-source.c

@@ -1342,6 +1342,10 @@ void obs_source_filter_remove(obs_source_t *source, obs_source_t *filter)
 
 	calldata_free(&cd);
 
+	if (filter->info.filter_remove)
+		filter->info.filter_remove(filter->context.data,
+				filter->filter_parent);
+
 	filter->filter_parent = NULL;
 	filter->filter_target = NULL;
 

+ 8 - 0
libobs/obs-source.h

@@ -364,6 +364,14 @@ struct obs_source_info {
 	 * @param source       Transitioning sub-source to get the volume of
 	 */
 	float (*get_transition_volume)(void *data, obs_source_t *source);
+
+	/**
+	 * Called when the filter is removed from a source
+	 *
+	 * @param  data    Filter data
+	 * @param  source  Source that the filter being removed from
+	 */
+	void (*filter_remove)(void *data, obs_source_t *source);
 };
 
 EXPORT void obs_register_source_s(const struct obs_source_info *info,