mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
code: Migrate filter::dynamic_mask to new dynamic loader
This commit is contained in:
parent
4d913c34f5
commit
1059e5c027
3 changed files with 20 additions and 28 deletions
|
@ -822,26 +822,27 @@ bool dynamic_mask_factory::on_manual_open(obs_properties_t* props, obs_property_
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::shared_ptr<dynamic_mask_factory> _filter_dynamic_mask_factory_instance = nullptr;
|
std::shared_ptr<dynamic_mask_factory> dynamic_mask_factory::instance()
|
||||||
|
|
||||||
void streamfx::filter::dynamic_mask::dynamic_mask_factory::initialize()
|
|
||||||
{
|
{
|
||||||
try {
|
static std::weak_ptr<dynamic_mask_factory> winst;
|
||||||
if (!_filter_dynamic_mask_factory_instance)
|
static std::mutex mtx;
|
||||||
_filter_dynamic_mask_factory_instance = std::make_shared<dynamic_mask_factory>();
|
|
||||||
} catch (const std::exception& ex) {
|
std::unique_lock<decltype(mtx)> lock(mtx);
|
||||||
D_LOG_ERROR("Failed to initialize due to error: %s", ex.what());
|
auto instance = winst.lock();
|
||||||
} catch (...) {
|
if (!instance) {
|
||||||
D_LOG_ERROR("Failed to initialize due to unknown error.", "");
|
instance = std::shared_ptr<dynamic_mask_factory>(new dynamic_mask_factory());
|
||||||
|
winst = instance;
|
||||||
}
|
}
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamfx::filter::dynamic_mask::dynamic_mask_factory::finalize()
|
static std::shared_ptr<dynamic_mask_factory> loader_instance;
|
||||||
{
|
|
||||||
_filter_dynamic_mask_factory_instance.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<dynamic_mask_factory> streamfx::filter::dynamic_mask::dynamic_mask_factory::get()
|
static auto loader = streamfx::loader(
|
||||||
{
|
[]() { // Initalizer
|
||||||
return _filter_dynamic_mask_factory_instance;
|
loader_instance = dynamic_mask_factory::instance();
|
||||||
}
|
},
|
||||||
|
[]() { // Finalizer
|
||||||
|
loader_instance.reset();
|
||||||
|
},
|
||||||
|
streamfx::loader_priority::NORMAL);
|
||||||
|
|
|
@ -133,6 +133,6 @@ namespace streamfx::filter::dynamic_mask {
|
||||||
|
|
||||||
static void finalize();
|
static void finalize();
|
||||||
|
|
||||||
static std::shared_ptr<dynamic_mask_factory> get();
|
static std::shared_ptr<dynamic_mask_factory> instance();
|
||||||
};
|
};
|
||||||
} // namespace streamfx::filter::dynamic_mask
|
} // namespace streamfx::filter::dynamic_mask
|
||||||
|
|
|
@ -28,9 +28,6 @@
|
||||||
#ifdef ENABLE_FILTER_DISPLACEMENT
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
||||||
#include "filters/filter-displacement.hpp"
|
#include "filters/filter-displacement.hpp"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
|
||||||
#include "filters/filter-dynamic-mask.hpp"
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
||||||
#include "filters/filter-sdf-effects.hpp"
|
#include "filters/filter-sdf-effects.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -156,9 +153,6 @@ MODULE_EXPORT bool obs_module_load(void)
|
||||||
#ifdef ENABLE_FILTER_DISPLACEMENT
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
||||||
streamfx::filter::displacement::displacement_factory::initialize();
|
streamfx::filter::displacement::displacement_factory::initialize();
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
|
||||||
streamfx::filter::dynamic_mask::dynamic_mask_factory::initialize();
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
||||||
streamfx::filter::sdf_effects::sdf_effects_factory::initialize();
|
streamfx::filter::sdf_effects::sdf_effects_factory::initialize();
|
||||||
#endif
|
#endif
|
||||||
|
@ -214,9 +208,6 @@ MODULE_EXPORT void obs_module_unload(void)
|
||||||
#ifdef ENABLE_FILTER_DISPLACEMENT
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
||||||
streamfx::filter::displacement::displacement_factory::finalize();
|
streamfx::filter::displacement::displacement_factory::finalize();
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
|
||||||
streamfx::filter::dynamic_mask::dynamic_mask_factory::finalize();
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
||||||
streamfx::filter::sdf_effects::sdf_effects_factory::finalize();
|
streamfx::filter::sdf_effects::sdf_effects_factory::finalize();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue