mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
code: Migrate filter::transform to new dynamic loader
This commit is contained in:
parent
8bec18600f
commit
4d913c34f5
3 changed files with 20 additions and 32 deletions
|
@ -810,26 +810,27 @@ bool transform_factory::on_manual_open(obs_properties_t* props, obs_property_t*
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::shared_ptr<transform_factory> _filter_transform_factory_instance = nullptr;
|
std::shared_ptr<transform_factory> transform_factory::instance()
|
||||||
|
|
||||||
void transform_factory::initialize()
|
|
||||||
{
|
{
|
||||||
try {
|
static std::weak_ptr<transform_factory> winst;
|
||||||
if (!_filter_transform_factory_instance)
|
static std::mutex mtx;
|
||||||
_filter_transform_factory_instance = std::make_shared<transform_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<transform_factory>(new transform_factory());
|
||||||
|
winst = instance;
|
||||||
}
|
}
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void transform_factory::finalize()
|
static std::shared_ptr<transform_factory> loader_instance;
|
||||||
{
|
|
||||||
_filter_transform_factory_instance.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<transform_factory> transform_factory::get()
|
static auto loader = streamfx::loader(
|
||||||
{
|
[]() { // Initalizer
|
||||||
return _filter_transform_factory_instance;
|
loader_instance = transform_factory::instance();
|
||||||
}
|
},
|
||||||
|
[]() { // Finalizer
|
||||||
|
loader_instance.reset();
|
||||||
|
},
|
||||||
|
streamfx::loader_priority::NORMAL);
|
||||||
|
|
|
@ -96,10 +96,6 @@ namespace streamfx::filter::transform {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public: // Singleton
|
public: // Singleton
|
||||||
static void initialize();
|
static std::shared_ptr<transform_factory> instance();
|
||||||
|
|
||||||
static void finalize();
|
|
||||||
|
|
||||||
static std::shared_ptr<transform_factory> get();
|
|
||||||
};
|
};
|
||||||
} // namespace streamfx::filter::transform
|
} // namespace streamfx::filter::transform
|
||||||
|
|
|
@ -34,9 +34,6 @@
|
||||||
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
||||||
#include "filters/filter-sdf-effects.hpp"
|
#include "filters/filter-sdf-effects.hpp"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_FILTER_TRANSFORM
|
|
||||||
#include "filters/filter-transform.hpp"
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_FILTER_UPSCALING
|
#ifdef ENABLE_FILTER_UPSCALING
|
||||||
#include "filters/filter-upscaling.hpp"
|
#include "filters/filter-upscaling.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -165,9 +162,6 @@ MODULE_EXPORT bool obs_module_load(void)
|
||||||
#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
|
||||||
#ifdef ENABLE_FILTER_TRANSFORM
|
|
||||||
streamfx::filter::transform::transform_factory::initialize();
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_FILTER_UPSCALING
|
#ifdef ENABLE_FILTER_UPSCALING
|
||||||
streamfx::filter::upscaling::upscaling_factory::initialize();
|
streamfx::filter::upscaling::upscaling_factory::initialize();
|
||||||
#endif
|
#endif
|
||||||
|
@ -226,9 +220,6 @@ MODULE_EXPORT void obs_module_unload(void)
|
||||||
#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
|
||||||
#ifdef ENABLE_FILTER_TRANSFORM
|
|
||||||
streamfx::filter::transform::transform_factory::finalize();
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_FILTER_UPSCALING
|
#ifdef ENABLE_FILTER_UPSCALING
|
||||||
streamfx::filter::upscaling::upscaling_factory::finalize();
|
streamfx::filter::upscaling::upscaling_factory::finalize();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue