mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-23 20:05:11 +00:00
code: Migrate filter::color_grade to new dynamic loader
This commit is contained in:
parent
1363b14288
commit
765e663180
3 changed files with 26 additions and 32 deletions
|
@ -826,26 +826,33 @@ bool color_grade_factory::on_manual_open(obs_properties_t* props, obs_property_t
|
|||
}
|
||||
#endif
|
||||
|
||||
std::shared_ptr<color_grade_factory> _color_grade_factory_instance = nullptr;
|
||||
|
||||
void streamfx::filter::color_grade::color_grade_factory::initialize()
|
||||
std::shared_ptr<color_grade_factory> streamfx::filter::color_grade::color_grade_factory::instance()
|
||||
{
|
||||
try {
|
||||
if (!_color_grade_factory_instance)
|
||||
_color_grade_factory_instance = std::make_shared<color_grade_factory>();
|
||||
} catch (const std::exception& ex) {
|
||||
D_LOG_ERROR("Failed to initialize due to error: %s", ex.what());
|
||||
} catch (...) {
|
||||
D_LOG_ERROR("Failed to initialize due to unknown error.", "");
|
||||
static std::weak_ptr<color_grade_factory> winst;
|
||||
static std::mutex mtx;
|
||||
|
||||
std::unique_lock<decltype(mtx)> lock(mtx);
|
||||
auto instance = winst.lock();
|
||||
if (!instance) {
|
||||
try {
|
||||
instance = std::shared_ptr<color_grade_factory>(new color_grade_factory());
|
||||
winst = instance;
|
||||
} catch (const std::exception& ex) {
|
||||
D_LOG_ERROR("Failed to initialize due to error: %s", ex.what());
|
||||
} catch (...) {
|
||||
D_LOG_ERROR("Failed to initialize due to unknown error.", "");
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void streamfx::filter::color_grade::color_grade_factory::finalize()
|
||||
{
|
||||
_color_grade_factory_instance.reset();
|
||||
}
|
||||
static std::shared_ptr<color_grade_factory> loader_instance;
|
||||
|
||||
std::shared_ptr<color_grade_factory> streamfx::filter::color_grade::color_grade_factory::get()
|
||||
{
|
||||
return _color_grade_factory_instance;
|
||||
}
|
||||
static auto loader = streamfx::loader(
|
||||
[]() { // Initalizer
|
||||
loader_instance = color_grade_factory::instance();
|
||||
},
|
||||
[]() { // Finalizer
|
||||
loader_instance.reset();
|
||||
},
|
||||
streamfx::loader_priority::NORMAL); // Must be loaded after all other functionality.
|
||||
|
|
|
@ -103,10 +103,6 @@ namespace streamfx::filter::color_grade {
|
|||
#endif
|
||||
|
||||
public: // Singleton
|
||||
static void initialize();
|
||||
|
||||
static void finalize();
|
||||
|
||||
static std::shared_ptr<color_grade_factory> get();
|
||||
static std::shared_ptr<color_grade_factory> instance();
|
||||
};
|
||||
} // namespace streamfx::filter::color_grade
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
#ifdef ENABLE_FILTER_BLUR
|
||||
#include "filters/filter-blur.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_FILTER_COLOR_GRADE
|
||||
#include "filters/filter-color-grade.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_FILTER_DENOISING
|
||||
#include "filters/filter-denoising.hpp"
|
||||
#endif
|
||||
|
@ -162,9 +159,6 @@ MODULE_EXPORT bool obs_module_load(void)
|
|||
#ifdef ENABLE_FILTER_BLUR
|
||||
streamfx::filter::blur::blur_factory::initialize();
|
||||
#endif
|
||||
#ifdef ENABLE_FILTER_COLOR_GRADE
|
||||
streamfx::filter::color_grade::color_grade_factory::initialize();
|
||||
#endif
|
||||
#ifdef ENABLE_FILTER_DENOISING
|
||||
streamfx::filter::denoising::denoising_factory::initialize();
|
||||
#endif
|
||||
|
@ -235,9 +229,6 @@ MODULE_EXPORT void obs_module_unload(void)
|
|||
#ifdef ENABLE_FILTER_BLUR
|
||||
streamfx::filter::blur::blur_factory::finalize();
|
||||
#endif
|
||||
#ifdef ENABLE_FILTER_COLOR_GRADE
|
||||
streamfx::filter::color_grade::color_grade_factory::finalize();
|
||||
#endif
|
||||
#ifdef ENABLE_FILTER_DENOISING
|
||||
streamfx::filter::denoising::denoising_factory::finalize();
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue