obs-source: Deprecate obs::source due to stability issues
This should be replaced with a class inheriting from std::shared_ptr.
This commit is contained in:
		
							parent
							
								
									6ce6ffe5bd
								
							
						
					
					
						commit
						cbada3e438
					
				|  | @ -76,7 +76,7 @@ void filter::dynamic_mask::dynamic_mask_instance::update(obs_data_t* settings) | |||
| { | ||||
| 	// Update source.
 | ||||
| 	try { | ||||
| 		_input         = std::make_shared<obs::source>(obs_data_get_string(settings, ST_INPUT)); | ||||
| 		_input         = std::make_shared<obs::deprecated_source>(obs_data_get_string(settings, ST_INPUT)); | ||||
| 		_input_capture = std::make_shared<gfx::source_texture>(_input, _self); | ||||
| 		_input->events.rename += std::bind(&filter::dynamic_mask::dynamic_mask_instance::input_renamed, this, | ||||
| 										   std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); | ||||
|  | @ -169,7 +169,7 @@ void filter::dynamic_mask::dynamic_mask_instance::save(obs_data_t* settings) | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void filter::dynamic_mask::dynamic_mask_instance::input_renamed(obs::source*, std::string old_name, | ||||
| void filter::dynamic_mask::dynamic_mask_instance::input_renamed(obs::deprecated_source*, std::string old_name, | ||||
| 																std::string new_name) | ||||
| { | ||||
| 	obs_data_t* settings = obs_source_get_settings(_self); | ||||
|  |  | |||
|  | @ -53,10 +53,10 @@ namespace filter { | |||
| 			std::shared_ptr<gs::rendertarget> _filter_rt; | ||||
| 			std::shared_ptr<gs::texture>      _filter_texture; | ||||
| 
 | ||||
| 			bool                                 _have_input_texture; | ||||
| 			std::shared_ptr<obs::source>         _input; | ||||
| 			std::shared_ptr<gfx::source_texture> _input_capture; | ||||
| 			std::shared_ptr<gs::texture>         _input_texture; | ||||
| 			bool                                    _have_input_texture; | ||||
| 			std::shared_ptr<obs::deprecated_source> _input; | ||||
| 			std::shared_ptr<gfx::source_texture>    _input_capture; | ||||
| 			std::shared_ptr<gs::texture>            _input_texture; | ||||
| 
 | ||||
| 			bool                              _have_final_texture; | ||||
| 			std::shared_ptr<gs::rendertarget> _final_rt; | ||||
|  | @ -83,7 +83,7 @@ namespace filter { | |||
| 			virtual void load(obs_data_t* settings) override; | ||||
| 			virtual void save(obs_data_t* settings) override; | ||||
| 
 | ||||
| 			void input_renamed(obs::source* src, std::string old_name, std::string new_name); | ||||
| 			void input_renamed(obs::deprecated_source* src, std::string old_name, std::string new_name); | ||||
| 
 | ||||
| 			static bool modified(void* self, obs_properties_t* properties, obs_property_t* property, | ||||
| 								 obs_data_t* settings) noexcept; | ||||
|  |  | |||
|  | @ -33,7 +33,7 @@ gfx::source_texture::source_texture(obs_source_t* parent) | |||
| 	if (!parent) { | ||||
| 		throw std::invalid_argument("_parent must not be null"); | ||||
| 	} | ||||
| 	_parent = std::make_shared<obs::source>(parent, false, false); | ||||
| 	_parent = std::make_shared<obs::deprecated_source>(parent, false, false); | ||||
| 	_rt     = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE); | ||||
| } | ||||
| 
 | ||||
|  | @ -45,7 +45,7 @@ gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent | |||
| 	if (!obs_source_add_active_child(_parent, _source)) { | ||||
| 		throw std::runtime_error("_parent is contained in _child"); | ||||
| 	} | ||||
| 	_child = std::make_shared<obs::source>(_source, true, true); | ||||
| 	_child = std::make_shared<obs::deprecated_source>(_source, true, true); | ||||
| } | ||||
| 
 | ||||
| gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : source_texture(_parent) | ||||
|  | @ -53,7 +53,7 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : | |||
| 	if (!_name) { | ||||
| 		throw std::invalid_argument("name must not be null"); | ||||
| 	} | ||||
| 	_child = std::make_shared<obs::source>(_name, true, true); | ||||
| 	_child = std::make_shared<obs::deprecated_source>(_name, true, true); | ||||
| 	if (!obs_source_add_active_child(_parent, _child->get())) { | ||||
| 		throw std::runtime_error("_parent is contained in _child"); | ||||
| 	} | ||||
|  | @ -62,7 +62,8 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : | |||
| gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent) : source_texture(_name.c_str(), _parent) | ||||
| {} | ||||
| 
 | ||||
| gfx::source_texture::source_texture(std::shared_ptr<obs::source> pchild, std::shared_ptr<obs::source> pparent) | ||||
| gfx::source_texture::source_texture(std::shared_ptr<obs::deprecated_source> pchild, | ||||
| 									std::shared_ptr<obs::deprecated_source> pparent) | ||||
| { | ||||
| 	if (!pchild) { | ||||
| 		throw std::invalid_argument("_child must not be null"); | ||||
|  | @ -78,8 +79,8 @@ gfx::source_texture::source_texture(std::shared_ptr<obs::source> pchild, std::sh | |||
| 	this->_rt     = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE); | ||||
| } | ||||
| 
 | ||||
| gfx::source_texture::source_texture(std::shared_ptr<obs::source> _child, obs_source_t* _parent) | ||||
| 	: source_texture(_child, std::make_shared<obs::source>(_parent, false, false)) | ||||
| gfx::source_texture::source_texture(std::shared_ptr<obs::deprecated_source> _child, obs_source_t* _parent) | ||||
| 	: source_texture(_child, std::make_shared<obs::deprecated_source>(_parent, false, false)) | ||||
| {} | ||||
| 
 | ||||
| obs_source_t* gfx::source_texture::get_object() | ||||
|  |  | |||
|  | @ -16,6 +16,7 @@ | |||
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 | ||||
| 
 | ||||
| #pragma once | ||||
| #include <map> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include "obs/gs/gs-rendertarget.hpp" | ||||
|  | @ -34,8 +35,8 @@ | |||
| 
 | ||||
| namespace gfx { | ||||
| 	class source_texture { | ||||
| 		std::shared_ptr<obs::source> _parent; | ||||
| 		std::shared_ptr<obs::source> _child; | ||||
| 		std::shared_ptr<obs::deprecated_source> _parent; | ||||
| 		std::shared_ptr<obs::deprecated_source> _child; | ||||
| 
 | ||||
| 		std::shared_ptr<gs::rendertarget> _rt; | ||||
| 
 | ||||
|  | @ -47,8 +48,8 @@ namespace gfx { | |||
| 		source_texture(const char* name, obs_source_t* parent); | ||||
| 		source_texture(std::string name, obs_source_t* parent); | ||||
| 
 | ||||
| 		source_texture(std::shared_ptr<obs::source> child, std::shared_ptr<obs::source> parent); | ||||
| 		source_texture(std::shared_ptr<obs::source> child, obs_source_t* parent); | ||||
| 		source_texture(std::shared_ptr<obs::deprecated_source> child, std::shared_ptr<obs::deprecated_source> parent); | ||||
| 		source_texture(std::shared_ptr<obs::deprecated_source> child, obs_source_t* parent); | ||||
| 
 | ||||
| 		public /*copy*/: | ||||
| 		source_texture(source_texture const& other) = delete; | ||||
|  | @ -67,4 +68,38 @@ namespace gfx { | |||
| 		obs_source_t* get_object(); | ||||
| 		obs_source_t* get_parent(); | ||||
| 	}; | ||||
| 
 | ||||
| 	class source_texture_factory { | ||||
| 		friend class source_texture; | ||||
| 
 | ||||
| 		std::map<std::shared_ptr<obs_weak_source_t>, std::weak_ptr<source_texture>> _cache; | ||||
| 
 | ||||
| 		public: | ||||
| 		source_texture_factory(); | ||||
| 		~source_texture_factory(); | ||||
| 
 | ||||
| 		std::shared_ptr<source_texture> get_source_texture(std::shared_ptr<obs_source_t> source); | ||||
| 
 | ||||
| 		protected: | ||||
| 		void free_source_texture(std::shared_ptr<obs_source_t> source); | ||||
| 
 | ||||
| 		private: // Singleton
 | ||||
| 		static std::shared_ptr<source_texture_factory> factory_instance; | ||||
| 
 | ||||
| 		public: // Singleton
 | ||||
| 		static void initialize() | ||||
| 		{ | ||||
| 			factory_instance = std::make_shared<source_texture_factory>(); | ||||
| 		} | ||||
| 
 | ||||
| 		static void finalize() | ||||
| 		{ | ||||
| 			factory_instance.reset(); | ||||
| 		} | ||||
| 
 | ||||
| 		static std::shared_ptr<source_texture_factory> get() | ||||
| 		{ | ||||
| 			return factory_instance; | ||||
| 		} | ||||
| 	}; | ||||
| } // namespace gfx
 | ||||
|  |  | |||
|  | @ -21,8 +21,9 @@ | |||
| #include <stdexcept> | ||||
| #include "plugin.hpp" | ||||
| 
 | ||||
| void obs::source::handle_destroy(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_destroy(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 
 | ||||
| 	obs_source_t* source; | ||||
| 	if (!calldata_get_ptr(calldata, "source", &source)) { | ||||
|  | @ -43,8 +44,9 @@ void obs::source::handle_destroy(void* p, calldata_t* calldata) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_remove(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_remove(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.remove) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -55,8 +57,9 @@ void obs::source::handle_remove(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_save(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_save(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.save) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -67,8 +70,9 @@ void obs::source::handle_save(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_load(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_load(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.load) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -79,8 +83,9 @@ void obs::source::handle_load(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_activate(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_activate(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.activate) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -91,8 +96,9 @@ void obs::source::handle_activate(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_deactivate(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_deactivate(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.deactivate) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -103,8 +109,9 @@ void obs::source::handle_deactivate(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_show(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_show(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.show) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -115,8 +122,9 @@ void obs::source::handle_show(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_hide(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_hide(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.hide) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -127,8 +135,9 @@ void obs::source::handle_hide(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_enable(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_enable(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.enable) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -145,8 +154,9 @@ void obs::source::handle_enable(void* p, calldata_t* calldata) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_push_to_mute_changed(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_push_to_mute_changed(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.push_to_mute_changed) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -163,8 +173,9 @@ void obs::source::handle_push_to_mute_changed(void* p, calldata_t* calldata) noe | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_push_to_mute_delay(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_push_to_mute_delay(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.push_to_mute_delay) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -181,8 +192,9 @@ void obs::source::handle_push_to_mute_delay(void* p, calldata_t* calldata) noexc | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_push_to_talk_changed(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_push_to_talk_changed(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.push_to_talk_changed) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -199,8 +211,9 @@ void obs::source::handle_push_to_talk_changed(void* p, calldata_t* calldata) noe | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_push_to_talk_delay(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_push_to_talk_delay(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.push_to_talk_delay) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -217,8 +230,9 @@ void obs::source::handle_push_to_talk_delay(void* p, calldata_t* calldata) noexc | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_rename(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_rename(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.enable) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -240,8 +254,9 @@ void obs::source::handle_rename(void* p, calldata_t* calldata) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_update_properties(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_update_properties(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.update_properties) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -252,8 +267,9 @@ void obs::source::handle_update_properties(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_update_flags(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_update_flags(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.update_flags) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -270,8 +286,9 @@ void obs::source::handle_update_flags(void* p, calldata_t* calldata) noexcept tr | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_mute(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_mute(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.mute) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -288,8 +305,9 @@ void obs::source::handle_mute(void* p, calldata_t* calldata) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_volume(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_volume(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.volume) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -308,8 +326,9 @@ void obs::source::handle_volume(void* p, calldata_t* calldata) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_audio_sync(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_audio_sync(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.audio_sync) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -328,8 +347,9 @@ void obs::source::handle_audio_sync(void* p, calldata_t* calldata) noexcept try | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_audio_mixers(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_audio_mixers(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.audio_mixers) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -348,8 +368,9 @@ void obs::source::handle_audio_mixers(void* p, calldata_t* calldata) noexcept tr | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_audio_data(void* p, obs_source_t*, const audio_data* audio, bool muted) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_audio_data(void* p, obs_source_t*, const audio_data* audio, bool muted) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.audio_data) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -361,8 +382,9 @@ void obs::source::handle_audio_data(void* p, obs_source_t*, const audio_data* au | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_filter_add(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_filter_add(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.filter_add) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -379,8 +401,9 @@ void obs::source::handle_filter_add(void* p, calldata_t* calldata) noexcept try | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_filter_remove(void* p, calldata_t* calldata) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_filter_remove(void* p, calldata_t* calldata) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.filter_remove) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -397,8 +420,9 @@ void obs::source::handle_filter_remove(void* p, calldata_t* calldata) noexcept t | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_reorder_filters(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_reorder_filters(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.reorder_filters) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -409,8 +433,9 @@ void obs::source::handle_reorder_filters(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_transition_start(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_transition_start(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.transition_start) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -421,8 +446,9 @@ void obs::source::handle_transition_start(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_transition_video_stop(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_transition_video_stop(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.transition_video_stop) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -433,8 +459,9 @@ void obs::source::handle_transition_video_stop(void* p, calldata_t*) noexcept tr | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| void obs::source::handle_transition_stop(void* p, calldata_t*) noexcept try { | ||||
| 	obs::source* self = reinterpret_cast<obs::source*>(p); | ||||
| void obs::deprecated_source::handle_transition_stop(void* p, calldata_t*) noexcept | ||||
| try { | ||||
| 	obs::deprecated_source* self = reinterpret_cast<obs::deprecated_source*>(p); | ||||
| 	if (!self->events.transition_stop) { | ||||
| 		return; | ||||
| 	} | ||||
|  | @ -445,7 +472,7 @@ void obs::source::handle_transition_stop(void* p, calldata_t*) noexcept try { | |||
| 	P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); | ||||
| } | ||||
| 
 | ||||
| obs::source::~source() | ||||
| obs::deprecated_source::~deprecated_source() | ||||
| { | ||||
| #ifdef auto_signal_d | ||||
| #undef auto_signal_d | ||||
|  | @ -486,29 +513,29 @@ obs::source::~source() | |||
| 	this->_self = nullptr; | ||||
| } | ||||
| 
 | ||||
| obs::source::source() | ||||
| obs::deprecated_source::deprecated_source() | ||||
| { | ||||
| #ifdef auto_signal_c | ||||
| #undef auto_signal_c | ||||
| #endif | ||||
| #define auto_signal_c(SIGNAL)                                                                  \ | ||||
| 	{                                                                                          \ | ||||
| 		this->events.SIGNAL.set_listen_callback([this]() noexcept {                            \ | ||||
| 			if (!this->_self)                                                                  \ | ||||
| 				return;                                                                        \ | ||||
| 			auto sh = obs_source_get_signal_handler(this->_self);                              \ | ||||
| 			if (sh) {                                                                          \ | ||||
| 				signal_handler_connect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this);    \ | ||||
| 			}                                                                                  \ | ||||
| 		});                                                                                    \ | ||||
| 		this->events.SIGNAL.set_silence_callback([this]() noexcept {                           \ | ||||
| 			if (!this->_self)                                                                  \ | ||||
| 				return;                                                                        \ | ||||
| 			auto sh = obs_source_get_signal_handler(this->_self);                              \ | ||||
| 			if (sh) {                                                                          \ | ||||
| 				signal_handler_disconnect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ | ||||
| 			}                                                                                  \ | ||||
| 		});                                                                                    \ | ||||
| #define auto_signal_c(SIGNAL)                                                                             \ | ||||
| 	{                                                                                                     \ | ||||
| 		this->events.SIGNAL.set_listen_callback([this]() noexcept {                                       \ | ||||
| 			if (!this->_self)                                                                             \ | ||||
| 				return;                                                                                   \ | ||||
| 			auto sh = obs_source_get_signal_handler(this->_self);                                         \ | ||||
| 			if (sh) {                                                                                     \ | ||||
| 				signal_handler_connect(sh, "" #SIGNAL, obs::deprecated_source::handle_##SIGNAL, this);    \ | ||||
| 			}                                                                                             \ | ||||
| 		});                                                                                               \ | ||||
| 		this->events.SIGNAL.set_silence_callback([this]() noexcept {                                      \ | ||||
| 			if (!this->_self)                                                                             \ | ||||
| 				return;                                                                                   \ | ||||
| 			auto sh = obs_source_get_signal_handler(this->_self);                                         \ | ||||
| 			if (sh) {                                                                                     \ | ||||
| 				signal_handler_disconnect(sh, "" #SIGNAL, obs::deprecated_source::handle_##SIGNAL, this); \ | ||||
| 			}                                                                                             \ | ||||
| 		});                                                                                               \ | ||||
| 	} | ||||
| 	auto_signal_c(destroy) auto_signal_c(remove) auto_signal_c(save) auto_signal_c(load) auto_signal_c(activate) | ||||
| 		auto_signal_c(deactivate) auto_signal_c(show) auto_signal_c(hide) auto_signal_c(mute) | ||||
|  | @ -526,17 +553,18 @@ obs::source::source() | |||
| 		this->events.audio_data.set_listen_callback([this]() noexcept { | ||||
| 			if (!this->_self) | ||||
| 				return; | ||||
| 			obs_source_add_audio_capture_callback(this->_self, obs::source::handle_audio_data, this); | ||||
| 			obs_source_add_audio_capture_callback(this->_self, obs::deprecated_source::handle_audio_data, this); | ||||
| 		}); | ||||
| 		this->events.audio_data.set_silence_callback([this]() noexcept { | ||||
| 			if (!this->_self) | ||||
| 				return; | ||||
| 			obs_source_remove_audio_capture_callback(this->_self, obs::source::handle_audio_data, this); | ||||
| 			obs_source_remove_audio_capture_callback(this->_self, obs::deprecated_source::handle_audio_data, this); | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| obs::source::source(std::string name, bool ptrack_ownership, bool add_reference) : ::obs::source::source() | ||||
| obs::deprecated_source::deprecated_source(std::string name, bool ptrack_ownership, bool add_reference) | ||||
| 	: ::obs::deprecated_source::deprecated_source() | ||||
| { | ||||
| 	this->_self = obs_get_source_by_name(name.c_str()); | ||||
| 	if (!this->_self) { | ||||
|  | @ -549,7 +577,8 @@ obs::source::source(std::string name, bool ptrack_ownership, bool add_reference) | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| obs::source::source(obs_source_t* source, bool ptrack_ownership, bool add_reference) : ::obs::source::source() | ||||
| obs::deprecated_source::deprecated_source(obs_source_t* source, bool ptrack_ownership, bool add_reference) | ||||
| 	: ::obs::deprecated_source::deprecated_source() | ||||
| { | ||||
| 	this->_self = source; | ||||
| 	if (!this->_self) { | ||||
|  | @ -562,7 +591,7 @@ obs::source::source(obs_source_t* source, bool ptrack_ownership, bool add_refere | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| obs::source::source(source const& other) | ||||
| obs::deprecated_source::deprecated_source(deprecated_source const& other) | ||||
| { | ||||
| 	this->_self            = other._self; | ||||
| 	this->_track_ownership = other._track_ownership; | ||||
|  | @ -605,7 +634,7 @@ obs::source::source(source const& other) | |||
| #undef auto_signal_c | ||||
| } | ||||
| 
 | ||||
| obs::source& obs::source::operator=(source const& other) | ||||
| obs::deprecated_source& obs::deprecated_source::operator=(deprecated_source const& other) | ||||
| { | ||||
| 	if (this == &other) { | ||||
| 		return *this; | ||||
|  | @ -659,7 +688,8 @@ obs::source& obs::source::operator=(source const& other) | |||
| 	return *this; | ||||
| } | ||||
| 
 | ||||
| obs::source::source(source&& other) : _self(std::move(other._self)), _track_ownership(std::move(other._track_ownership)) | ||||
| obs::deprecated_source::deprecated_source(deprecated_source&& other) | ||||
| 	: _self(std::move(other._self)), _track_ownership(std::move(other._track_ownership)) | ||||
| { | ||||
| 	// Clean out other source
 | ||||
| 	other._self            = nullptr; | ||||
|  | @ -699,7 +729,7 @@ obs::source::source(source&& other) : _self(std::move(other._self)), _track_owne | |||
| #undef auto_signal_c | ||||
| } | ||||
| 
 | ||||
| obs::source& obs::source::operator=(source&& other) | ||||
| obs::deprecated_source& obs::deprecated_source::operator=(deprecated_source&& other) | ||||
| { | ||||
| 	if (this != &other) { | ||||
| 		return *this; | ||||
|  | @ -751,7 +781,7 @@ obs::source& obs::source::operator=(source&& other) | |||
| 	return *this; | ||||
| } | ||||
| 
 | ||||
| obs_source_type obs::source::type() | ||||
| obs_source_type obs::deprecated_source::type() | ||||
| { | ||||
| 	if (!_self) { | ||||
| 		return (obs_source_type)-1; | ||||
|  | @ -759,7 +789,7 @@ obs_source_type obs::source::type() | |||
| 	return obs_source_get_type(_self); | ||||
| } | ||||
| 
 | ||||
| void* obs::source::type_data() | ||||
| void* obs::deprecated_source::type_data() | ||||
| { | ||||
| 	if (!_self) { | ||||
| 		return nullptr; | ||||
|  | @ -767,7 +797,7 @@ void* obs::source::type_data() | |||
| 	return obs_source_get_type_data(_self); | ||||
| } | ||||
| 
 | ||||
| uint32_t obs::source::width() | ||||
| uint32_t obs::deprecated_source::width() | ||||
| { | ||||
| 	if (!_self) { | ||||
| 		return 0; | ||||
|  | @ -775,7 +805,7 @@ uint32_t obs::source::width() | |||
| 	return obs_source_get_width(_self); | ||||
| } | ||||
| 
 | ||||
| uint32_t obs::source::height() | ||||
| uint32_t obs::deprecated_source::height() | ||||
| { | ||||
| 	if (!_self) { | ||||
| 		return 0; | ||||
|  | @ -783,17 +813,17 @@ uint32_t obs::source::height() | |||
| 	return obs_source_get_height(_self); | ||||
| } | ||||
| 
 | ||||
| bool obs::source::destroyed() | ||||
| bool obs::deprecated_source::destroyed() | ||||
| { | ||||
| 	return _self == nullptr; | ||||
| } | ||||
| 
 | ||||
| void obs::source::clear() | ||||
| void obs::deprecated_source::clear() | ||||
| { | ||||
| 	_self = nullptr; | ||||
| } | ||||
| 
 | ||||
| obs_source_t* obs::source::get() | ||||
| obs_source_t* obs::deprecated_source::get() | ||||
| { | ||||
| 	return _self; | ||||
| } | ||||
|  |  | |||
|  | @ -36,7 +36,7 @@ | |||
| #endif | ||||
| 
 | ||||
| namespace obs { | ||||
| 	class source { | ||||
| 	class deprecated_source { | ||||
| 		obs_source_t* _self; | ||||
| 		bool          _track_ownership = false; | ||||
| 
 | ||||
|  | @ -69,21 +69,21 @@ namespace obs { | |||
| 		static void handle_transition_stop(void* p, calldata_t* calldata) noexcept; | ||||
| 
 | ||||
| 		public: | ||||
| 		virtual ~source(); | ||||
| 		virtual ~deprecated_source(); | ||||
| 
 | ||||
| 		source(); | ||||
| 		deprecated_source(); | ||||
| 
 | ||||
| 		source(std::string name, bool track_ownership = true, bool add_reference = true); | ||||
| 		deprecated_source(std::string name, bool track_ownership = true, bool add_reference = true); | ||||
| 
 | ||||
| 		source(obs_source_t* source, bool track_ownership = true, bool add_reference = false); | ||||
| 		deprecated_source(obs_source_t* source, bool track_ownership = true, bool add_reference = false); | ||||
| 
 | ||||
| 		public /*copy*/: | ||||
| 		source(source const& other); | ||||
| 		source& operator=(source const& other); | ||||
| 		deprecated_source(deprecated_source const& other); | ||||
| 		deprecated_source& operator=(deprecated_source const& other); | ||||
| 
 | ||||
| 		public /*move*/: | ||||
| 		source(source&& other); | ||||
| 		source& operator=(source&& other); | ||||
| 		deprecated_source(deprecated_source&& other); | ||||
| 		deprecated_source& operator=(deprecated_source&& other); | ||||
| 
 | ||||
| 		public: | ||||
| 		obs_source_type type(); | ||||
|  | @ -103,49 +103,49 @@ namespace obs { | |||
| 		public: // Events
 | ||||
| 		struct { | ||||
| 			// Destroy and Remove
 | ||||
| 			util::event<obs::source*> destroy; | ||||
| 			util::event<obs::source*> remove; | ||||
| 			util::event<obs::deprecated_source*> destroy; | ||||
| 			util::event<obs::deprecated_source*> remove; | ||||
| 
 | ||||
| 			// Saving, Loading and Update
 | ||||
| 			util::event<obs::source*> save; | ||||
| 			util::event<obs::source*> load; | ||||
| 			util::event<obs::source*> update_properties; | ||||
| 			util::event<obs::deprecated_source*> save; | ||||
| 			util::event<obs::deprecated_source*> load; | ||||
| 			util::event<obs::deprecated_source*> update_properties; | ||||
| 
 | ||||
| 			// Activate, Deactivate
 | ||||
| 			util::event<obs::source*> activate; | ||||
| 			util::event<obs::source*> deactivate; | ||||
| 			util::event<obs::deprecated_source*> activate; | ||||
| 			util::event<obs::deprecated_source*> deactivate; | ||||
| 
 | ||||
| 			// Show Hide
 | ||||
| 			util::event<obs::source*> show; | ||||
| 			util::event<obs::source*> hide; | ||||
| 			util::event<obs::deprecated_source*> show; | ||||
| 			util::event<obs::deprecated_source*> hide; | ||||
| 
 | ||||
| 			// Other
 | ||||
| 			util::event<obs::source*, bool>                     enable; | ||||
| 			util::event<obs::source*, std::string, std::string> rename; | ||||
| 			util::event<obs::source*, long long>                update_flags; | ||||
| 			util::event<obs::deprecated_source*, bool>                     enable; | ||||
| 			util::event<obs::deprecated_source*, std::string, std::string> rename; | ||||
| 			util::event<obs::deprecated_source*, long long>                update_flags; | ||||
| 
 | ||||
| 			// Hotkeys (PtM, PtT)
 | ||||
| 			util::event<obs::source*, bool>      push_to_mute_changed; | ||||
| 			util::event<obs::source*, long long> push_to_mute_delay; | ||||
| 			util::event<obs::source*, bool>      push_to_talk_changed; | ||||
| 			util::event<obs::source*, long long> push_to_talk_delay; | ||||
| 			util::event<obs::deprecated_source*, bool>      push_to_mute_changed; | ||||
| 			util::event<obs::deprecated_source*, long long> push_to_mute_delay; | ||||
| 			util::event<obs::deprecated_source*, bool>      push_to_talk_changed; | ||||
| 			util::event<obs::deprecated_source*, long long> push_to_talk_delay; | ||||
| 
 | ||||
| 			// Audio
 | ||||
| 			util::event<obs::source*, bool>                    mute; | ||||
| 			util::event<obs::source*, double&>                 volume; | ||||
| 			util::event<obs::source*, long long&>              audio_sync; | ||||
| 			util::event<obs::source*, long long&>              audio_mixers; | ||||
| 			util::event<obs::source*, const audio_data*, bool> audio_data; | ||||
| 			util::event<obs::deprecated_source*, bool>                    mute; | ||||
| 			util::event<obs::deprecated_source*, double&>                 volume; | ||||
| 			util::event<obs::deprecated_source*, long long&>              audio_sync; | ||||
| 			util::event<obs::deprecated_source*, long long&>              audio_mixers; | ||||
| 			util::event<obs::deprecated_source*, const audio_data*, bool> audio_data; | ||||
| 
 | ||||
| 			// Filters
 | ||||
| 			util::event<obs::source*, obs_source_t*> filter_add; | ||||
| 			util::event<obs::source*, obs_source_t*> filter_remove; | ||||
| 			util::event<obs::source*>                reorder_filters; | ||||
| 			util::event<obs::deprecated_source*, obs_source_t*> filter_add; | ||||
| 			util::event<obs::deprecated_source*, obs_source_t*> filter_remove; | ||||
| 			util::event<obs::deprecated_source*>                reorder_filters; | ||||
| 
 | ||||
| 			// Transition
 | ||||
| 			util::event<obs::source*> transition_start; | ||||
| 			util::event<obs::source*> transition_video_stop; | ||||
| 			util::event<obs::source*> transition_stop; | ||||
| 			util::event<obs::deprecated_source*> transition_start; | ||||
| 			util::event<obs::deprecated_source*> transition_video_stop; | ||||
| 			util::event<obs::deprecated_source*> transition_stop; | ||||
| 		} events; | ||||
| 	}; | ||||
| } // namespace obs
 | ||||
|  |  | |||
|  | @ -94,7 +94,7 @@ void source::mirror::mirror_instance::acquire(std::string source_name) | |||
| 	} | ||||
| 
 | ||||
| 	// It seems everything has worked out, so let's update our state.
 | ||||
| 	_source      = std::make_shared<obs::source>(source.get(), true, true); | ||||
| 	_source      = std::make_shared<obs::deprecated_source>(source.get(), true, true); | ||||
| 	_source_name = obs_source_get_name(source.get()); | ||||
| 	_source_item = std::shared_ptr<obs_sceneitem_t>(item, [](obs_sceneitem_t* ref) { obs_sceneitem_remove(ref); }); | ||||
| 
 | ||||
|  | @ -372,12 +372,12 @@ void source::mirror::mirror_instance::enum_all_sources(obs_source_enum_proc_t en | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void source::mirror::mirror_instance::on_source_rename(obs::source* source, std::string, std::string) | ||||
| void source::mirror::mirror_instance::on_source_rename(obs::deprecated_source* source, std::string, std::string) | ||||
| { | ||||
| 	obs_source_save(_self); | ||||
| } | ||||
| 
 | ||||
| void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_data* audio, bool) | ||||
| void source::mirror::mirror_instance::on_audio_data(obs::deprecated_source*, const audio_data* audio, bool) | ||||
| { | ||||
| 	if (!this->_audio_enabled) { | ||||
| 		return; | ||||
|  |  | |||
|  | @ -50,8 +50,8 @@ namespace source { | |||
| 
 | ||||
| 		class mirror_instance : public obs::source_instance { | ||||
| 			// Source
 | ||||
| 			std::shared_ptr<obs::source> _source; | ||||
| 			std::string                  _source_name; | ||||
| 			std::shared_ptr<obs::deprecated_source> _source; | ||||
| 			std::string                             _source_name; | ||||
| 
 | ||||
| 			// Cached Data
 | ||||
| 			std::pair<uint32_t, uint32_t> _source_size; | ||||
|  | @ -110,8 +110,8 @@ namespace source { | |||
| 
 | ||||
| 			void audio_output_cb() noexcept; | ||||
| 
 | ||||
| 			void on_source_rename(obs::source* source, std::string new_name, std::string old_name); | ||||
| 			void on_audio_data(obs::source* source, const audio_data* audio, bool muted); | ||||
| 			void on_source_rename(obs::deprecated_source* source, std::string new_name, std::string old_name); | ||||
| 			void on_audio_data(obs::deprecated_source* source, const audio_data* audio, bool muted); | ||||
| 		}; | ||||
| 
 | ||||
| 		class mirror_factory | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue