\r
#include <core/mixer/read_frame.h>\r
\r
-#include <common/concurrency/com_context.h>\r
+#include <common/concurrency/executor.h>\r
+#include <common/concurrency/lock.h>\r
#include <common/diagnostics/graph.h>\r
#include <common/exception/exceptions.h>\r
#include <common/memory/memshfl.h>\r
}\r
catch(...)\r
{\r
- tbb::spin_mutex::scoped_lock lock(exception_mutex_);\r
- exception_ = std::current_exception();\r
+ lock(exception_mutex_, [&]\r
+ {\r
+ exception_ = std::current_exception();\r
+ });\r
return E_FAIL;\r
}\r
\r
\r
void send(const safe_ptr<core::read_frame>& frame)\r
{\r
+ auto exception = lock(exception_mutex_, [&]\r
{\r
- tbb::spin_mutex::scoped_lock lock(exception_mutex_);\r
- if(exception_ != nullptr)\r
- std::rethrow_exception(exception_);\r
- }\r
+ return exception_;\r
+ });\r
+\r
+ if(exception != nullptr)\r
+ std::rethrow_exception(exception); \r
\r
if(!is_running_)\r
BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Is not running."));\r
\r
struct decklink_consumer_proxy : public core::frame_consumer\r
{\r
- const configuration config_;\r
- com_context<decklink_consumer> context_;\r
- std::vector<int> audio_cadence_;\r
+ const configuration config_;\r
+ std::unique_ptr<decklink_consumer> consumer_;\r
+ std::vector<int> audio_cadence_;\r
+ executor executor_;\r
public:\r
\r
decklink_consumer_proxy(const configuration& config)\r
: config_(config)\r
- , context_(L"decklink_consumer[" + boost::lexical_cast<std::wstring>(config.device_index) + L"]")\r
+ , executor_(L"decklink_consumer[" + boost::lexical_cast<std::wstring>(config.device_index) + L"]")\r
{\r
+ executor_.begin_invoke([=]\r
+ {\r
+ ::CoInitialize(nullptr);\r
+ });\r
}\r
\r
~decklink_consumer_proxy()\r
{\r
- if(context_)\r
+ executor_.invoke([=]\r
{\r
- auto str = print();\r
- context_.reset();\r
- CASPAR_LOG(info) << str << L" Successfully Uninitialized."; \r
- }\r
+ if(consumer_)\r
+ {\r
+ auto str = print();\r
+ consumer_.reset();\r
+ CASPAR_LOG(info) << str << L" Successfully Uninitialized."; \r
+ }\r
+ ::CoUninitialize();\r
+ });\r
}\r
\r
// frame_consumer\r
\r
virtual void initialize(const core::video_format_desc& format_desc, int channel_index) override\r
{\r
- context_.reset([&]{return new decklink_consumer(config_, format_desc, channel_index);}); \r
- audio_cadence_ = format_desc.audio_cadence; \r
+ executor_.invoke([=]\r
+ {\r
+ consumer_.reset(new decklink_consumer(config_, format_desc, channel_index)); \r
+ audio_cadence_ = format_desc.audio_cadence; \r
\r
- CASPAR_LOG(info) << print() << L" Successfully Initialized."; \r
+ CASPAR_LOG(info) << print() << L" Successfully Initialized."; \r
+ });\r
}\r
\r
virtual bool send(const safe_ptr<core::read_frame>& frame) override\r
CASPAR_VERIFY(audio_cadence_.front() == static_cast<int>(frame->audio_data().size()));\r
boost::range::rotate(audio_cadence_, std::begin(audio_cadence_)+1);\r
\r
- context_->send(frame);\r
+ consumer_->send(frame);\r
return true;\r
}\r
\r
virtual std::wstring print() const override\r
{\r
- return context_ ? context_->print() : L"[decklink_consumer]";\r
+ return consumer_ ? consumer_->print() : L"[decklink_consumer]";\r
} \r
\r
virtual boost::property_tree::wptree info() const override\r