]> git.sesse.net Git - casparcg/blobdiff - modules/decklink/consumer/decklink_consumer.cpp
2.0. flash_producer: Improved error handling.
[casparcg] / modules / decklink / consumer / decklink_consumer.cpp
index e8de3b3b8dc6e6a9fb4dcb8192cd86b519ca128d..b4c63c6552044f5b34117cc96049fb802b8bb57f 100644 (file)
@@ -103,6 +103,7 @@ struct decklink_consumer : public IDeckLinkVideoOutputCallback, public IDeckLink
        CComQIPtr<IDeckLinkConfiguration>       configuration_;\r
        CComQIPtr<IDeckLinkKeyer>                       keyer_;\r
 \r
+       tbb::spin_mutex                                         exception_mutex_;\r
        std::exception_ptr                                      exception_;\r
 \r
        tbb::atomic<bool>                                       is_running_;\r
@@ -296,6 +297,7 @@ public:
                }\r
                catch(...)\r
                {\r
+                       tbb::spin_mutex::scoped_lock lock(exception_mutex_);\r
                        exception_ = std::current_exception();\r
                        return E_FAIL;\r
                }\r
@@ -329,6 +331,7 @@ public:
                }\r
                catch(...)\r
                {\r
+                       tbb::spin_mutex::scoped_lock lock(exception_mutex_);\r
                        exception_ = std::current_exception();\r
                        return E_FAIL;\r
                }\r
@@ -358,8 +361,11 @@ public:
 \r
        void send(const safe_ptr<core::read_frame>& frame)\r
        {\r
-               if(exception_ != nullptr)\r
-                       std::rethrow_exception(exception_);\r
+               {\r
+                       tbb::spin_mutex::scoped_lock lock(exception_mutex_);\r
+                       if(exception_ != nullptr)\r
+                               std::rethrow_exception(exception_);\r
+               }\r
 \r
                if(!is_running_)\r
                        BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Is not running."));\r