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.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-11-29 04:21:22 +01:00
parent ad33066cd3
commit 716da4f6cc

View file

@ -36,6 +36,35 @@ namespace obs {
std::shared_ptr<obs_source_t> get(); std::shared_ptr<obs_source_t> 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 } // namespace tools
inline void obs_source_deleter(obs_source_t* v) inline void obs_source_deleter(obs_source_t* v)