]> git.sesse.net Git - casparcg/commitdiff
Removed monitor branch.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 29 Dec 2011 07:54:53 +0000 (07:54 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 29 Dec 2011 07:54:53 +0000 (07:54 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@1956 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

modules/decklink/consumer/decklink_consumer.cpp

index 033662944059470feac58b54159d0e3f38ffdf4f..803763bb54b558426ab7f129a8854a46b3b72421 100644 (file)
@@ -29,7 +29,8 @@
 \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
@@ -353,8 +354,10 @@ public:
                }\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
@@ -426,11 +429,13 @@ public:
 \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
@@ -449,35 +454,47 @@ public:
 \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
@@ -485,13 +502,13 @@ public:
                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