From 716da4f6cc1a77d37fcfa6f4a4b3e29de8398a25 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 29 Nov 2020 04:21:22 +0100 Subject: [PATCH] obs/tools: Add active_source and visible_source helpers These classes help us manage active and showing references to a source, which seem to be necessary for filters. --- source/obs/obs-tools.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/source/obs/obs-tools.hpp b/source/obs/obs-tools.hpp index 56c02be..38bb7c8 100644 --- a/source/obs/obs-tools.hpp +++ b/source/obs/obs-tools.hpp @@ -36,6 +36,35 @@ namespace obs { std::shared_ptr get(); }; + + // Class to manage + class active_source { + obs_source_t* _child; + + public: + active_source(obs_source_t* child) : _child(child) + { + obs_source_inc_active(_child); + } + virtual ~active_source() + { + obs_source_dec_active(_child); + } + }; + + class visible_source { + obs_source_t* _child; + + public: + visible_source(obs_source_t* child) : _child(child) + { + obs_source_inc_showing(_child); + } + virtual ~visible_source() + { + obs_source_dec_showing(_child); + } + }; } // namespace tools inline void obs_source_deleter(obs_source_t* v)