mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
code: Migrate obs::source_tracker to new dynamic loader
This commit is contained in:
parent
2f362efa38
commit
66698ef938
7 changed files with 32 additions and 29 deletions
|
@ -807,13 +807,13 @@ obs_properties_t* blur_factory::get_properties2(blur_instance* data)
|
||||||
/// Source
|
/// Source
|
||||||
p = obs_properties_add_list(pr, ST_KEY_MASK_SOURCE, D_TRANSLATE(ST_I18N_MASK_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
p = obs_properties_add_list(pr, ST_KEY_MASK_SOURCE, D_TRANSLATE(ST_I18N_MASK_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||||
obs_property_list_add_string(p, "", "");
|
obs_property_list_add_string(p, "", "");
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
obs_property_list_add_string(p, std::string(name + " (Source)").c_str(), name.c_str());
|
obs_property_list_add_string(p, std::string(name + " (Source)").c_str(), name.c_str());
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
obs::source_tracker::filter_video_sources);
|
obs::source_tracker::filter_video_sources);
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
obs_property_list_add_string(p, std::string(name + " (Scene)").c_str(), name.c_str());
|
obs_property_list_add_string(p, std::string(name + " (Scene)").c_str(), name.c_str());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -730,7 +730,7 @@ obs_properties_t* dynamic_mask_factory::get_properties2(dynamic_mask_instance* d
|
||||||
{ // Input
|
{ // Input
|
||||||
p = obs_properties_add_list(props, ST_KEY_INPUT, D_TRANSLATE(ST_I18N_INPUT), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
p = obs_properties_add_list(props, ST_KEY_INPUT, D_TRANSLATE(ST_I18N_INPUT), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||||
obs_property_list_add_string(p, "", "");
|
obs_property_list_add_string(p, "", "");
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SOURCE) << ")";
|
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SOURCE) << ")";
|
||||||
|
@ -738,7 +738,7 @@ obs_properties_t* dynamic_mask_factory::get_properties2(dynamic_mask_instance* d
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
obs::source_tracker::filter_video_sources);
|
obs::source_tracker::filter_video_sources);
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SCENE) << ")";
|
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SCENE) << ")";
|
||||||
|
|
|
@ -188,7 +188,7 @@ void streamfx::gfx::shader::texture_parameter::properties(obs_properties_t* prop
|
||||||
{
|
{
|
||||||
auto p = obs_properties_add_list(pr, _keys[2].c_str(), D_TRANSLATE(ST_I18N_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
auto p = obs_properties_add_list(pr, _keys[2].c_str(), D_TRANSLATE(ST_I18N_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||||
obs_property_list_add_string(p, "", "");
|
obs_property_list_add_string(p, "", "");
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SOURCE) << ")";
|
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SOURCE) << ")";
|
||||||
|
@ -196,7 +196,7 @@ void streamfx::gfx::shader::texture_parameter::properties(obs_properties_t* prop
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
obs::source_tracker::filter_video_sources);
|
obs::source_tracker::filter_video_sources);
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SCENE) << ")";
|
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SCENE) << ")";
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "obs-source-tracker.hpp"
|
#include "obs-source-tracker.hpp"
|
||||||
#include "obs/obs-tools.hpp"
|
#include "obs/obs-tools.hpp"
|
||||||
|
#include "plugin.hpp"
|
||||||
#include "util/util-logging.hpp"
|
#include "util/util-logging.hpp"
|
||||||
|
|
||||||
#include "warning-disable.hpp"
|
#include "warning-disable.hpp"
|
||||||
|
@ -235,17 +236,27 @@ void streamfx::obs::source_tracker::source_rename_handler(void* ptr, calldata_t*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<streamfx::obs::source_tracker> streamfx::obs::source_tracker::get()
|
std::shared_ptr<streamfx::obs::source_tracker> streamfx::obs::source_tracker::instance()
|
||||||
{
|
{
|
||||||
static std::mutex inst_mtx;
|
static std::weak_ptr<streamfx::obs::source_tracker> winst;
|
||||||
static std::weak_ptr<streamfx::obs::source_tracker> inst_weak;
|
static std::mutex mtx;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(inst_mtx);
|
std::unique_lock<decltype(mtx)> lock(mtx);
|
||||||
if (inst_weak.expired()) {
|
auto instance = winst.lock();
|
||||||
auto instance = std::shared_ptr<streamfx::obs::source_tracker>(new streamfx::obs::source_tracker());
|
if (!instance) {
|
||||||
inst_weak = instance;
|
instance = std::shared_ptr<streamfx::obs::source_tracker>(new streamfx::obs::source_tracker());
|
||||||
|
winst = instance;
|
||||||
|
}
|
||||||
return instance;
|
return instance;
|
||||||
} else {
|
|
||||||
return inst_weak.lock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::shared_ptr<streamfx::obs::source_tracker> loader_instance;
|
||||||
|
|
||||||
|
static auto loader = streamfx::loader(
|
||||||
|
[]() { // Initalizer
|
||||||
|
loader_instance = streamfx::obs::source_tracker::instance();
|
||||||
|
},
|
||||||
|
[]() { // Finalizer
|
||||||
|
loader_instance.reset();
|
||||||
|
},
|
||||||
|
streamfx::loader_priority::HIGHEST); // Does not rely on other critical functionality.
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace streamfx::obs {
|
||||||
// @return true to skip, false to pass along.
|
// @return true to skip, false to pass along.
|
||||||
typedef std::function<bool(std::string, ::streamfx::obs::source)> filter_cb_t;
|
typedef std::function<bool(std::string, ::streamfx::obs::source)> filter_cb_t;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
source_tracker();
|
source_tracker();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -62,6 +62,6 @@ namespace streamfx::obs {
|
||||||
static void source_rename_handler(void* ptr, calldata_t* data) noexcept;
|
static void source_rename_handler(void* ptr, calldata_t* data) noexcept;
|
||||||
|
|
||||||
public: // Singleton
|
public: // Singleton
|
||||||
static std::shared_ptr<streamfx::obs::source_tracker> get();
|
static std::shared_ptr<streamfx::obs::source_tracker> instance();
|
||||||
};
|
};
|
||||||
} // namespace streamfx::obs
|
} // namespace streamfx::obs
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "gfx/gfx-opengl.hpp"
|
#include "gfx/gfx-opengl.hpp"
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
#include "obs/gs/gs-vertexbuffer.hpp"
|
#include "obs/gs/gs-vertexbuffer.hpp"
|
||||||
#include "obs/obs-source-tracker.hpp"
|
|
||||||
|
|
||||||
#ifdef ENABLE_NVIDIA_CUDA
|
#ifdef ENABLE_NVIDIA_CUDA
|
||||||
#include "nvidia/cuda/nvidia-cuda-obs.hpp"
|
#include "nvidia/cuda/nvidia-cuda-obs.hpp"
|
||||||
|
@ -82,7 +81,6 @@
|
||||||
#include "warning-enable.hpp"
|
#include "warning-enable.hpp"
|
||||||
|
|
||||||
static std::shared_ptr<streamfx::gfx::opengl> _streamfx_gfx_opengl;
|
static std::shared_ptr<streamfx::gfx::opengl> _streamfx_gfx_opengl;
|
||||||
static std::shared_ptr<streamfx::obs::source_tracker> _source_tracker;
|
|
||||||
|
|
||||||
namespace streamfx {
|
namespace streamfx {
|
||||||
typedef std::list<loader_function_t> loader_list_t;
|
typedef std::list<loader_function_t> loader_list_t;
|
||||||
|
@ -138,9 +136,6 @@ MODULE_EXPORT bool obs_module_load(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Source Tracker
|
|
||||||
_source_tracker = streamfx::obs::source_tracker::get();
|
|
||||||
|
|
||||||
// Initialize GLAD (OpenGL)
|
// Initialize GLAD (OpenGL)
|
||||||
{
|
{
|
||||||
streamfx::obs::gs::context gctx{};
|
streamfx::obs::gs::context gctx{};
|
||||||
|
@ -320,9 +315,6 @@ MODULE_EXPORT void obs_module_unload(void)
|
||||||
_streamfx_gfx_opengl.reset();
|
_streamfx_gfx_opengl.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize Source Tracker
|
|
||||||
_source_tracker.reset();
|
|
||||||
|
|
||||||
// // Auto-Updater
|
// // Auto-Updater
|
||||||
//#ifdef ENABLE_UPDATER
|
//#ifdef ENABLE_UPDATER
|
||||||
// _updater.reset();
|
// _updater.reset();
|
||||||
|
|
|
@ -327,7 +327,7 @@ obs_properties_t* mirror_factory::get_properties2(mirror_instance* data)
|
||||||
obs_property_set_modified_callback(p, modified_properties);
|
obs_property_set_modified_callback(p, modified_properties);
|
||||||
|
|
||||||
obs_property_list_add_string(p, "", "");
|
obs_property_list_add_string(p, "", "");
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SOURCE) << ")";
|
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SOURCE) << ")";
|
||||||
|
@ -335,7 +335,7 @@ obs_properties_t* mirror_factory::get_properties2(mirror_instance* data)
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
obs::source_tracker::filter_sources);
|
obs::source_tracker::filter_sources);
|
||||||
obs::source_tracker::get()->enumerate(
|
obs::source_tracker::instance()->enumerate(
|
||||||
[&p](std::string name, ::streamfx::obs::source) {
|
[&p](std::string name, ::streamfx::obs::source) {
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SCENE) << ")";
|
sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SCENE) << ")";
|
||||||
|
|
Loading…
Reference in a new issue