]> git.sesse.net Git - casparcg/commitdiff
2.0. output: Try to recover consumers if they crash.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 19 Aug 2011 11:52:13 +0000 (11:52 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 19 Aug 2011 11:52:13 +0000 (11:52 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1229 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/consumer/output.cpp
core/video_channel.cpp
modules/bluefish/consumer/bluefish_consumer.cpp
modules/decklink/consumer/decklink_consumer.cpp
shell/casparcg.config

index ee0db5b5b0b033eb9b59dde0e5242ccaede11346..ad8d51003a58f5f1fa969f83b0558999b73ed50b 100644 (file)
@@ -130,24 +130,15 @@ public:
                auto it = consumers_.begin();\r
                while(it != consumers_.end())\r
                {\r
-                       try\r
-                       {\r
-                               auto consumer = it->second;\r
+                       auto consumer = it->second;\r
 \r
-                               if(consumer->get_video_format_desc() != channel_.get_format_desc())\r
-                                       consumer->initialize(channel_.get_format_desc());\r
+                       if(consumer->get_video_format_desc() != channel_.get_format_desc())\r
+                               consumer->initialize(channel_.get_format_desc());\r
 \r
-                               if(consumer->send(consumer->key_only() ? key : fill))\r
-                                       ++it;\r
-                               else\r
-                                       consumers_.erase(it++);\r
-                       }\r
-                       catch(...)\r
-                       {\r
-                               CASPAR_LOG_CURRENT_EXCEPTION();\r
-                               CASPAR_LOG(error) << print() << L" " << it->second->print() << L" Removed.";\r
+                       if(consumer->send(consumer->key_only() ? key : fill))\r
+                               ++it;\r
+                       else\r
                                consumers_.erase(it++);\r
-                       }\r
                }\r
        }\r
 \r
index 8abf2fbda41e15149c067f36b8af1e1518c47279..c1a37a78fe2c51814a73be1d0bc5ec8446562b92 100644 (file)
@@ -65,7 +65,7 @@ public:
                diag_->set_color("produce-time", diagnostics::color(0.0f, 1.0f, 0.0f));\r
                diag_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f));    \r
                diag_->set_color("output-time", diagnostics::color(1.0f, 0.5f, 0.0f));\r
-               diag_->set_color("mix-time", diagnostics::color(1.0f, 1.0f, 0.1f));\r
+               diag_->set_color("mix-time", diagnostics::color(1.0f, 1.0f, 0.9f));\r
 \r
                CASPAR_LOG(info) << print() << " Successfully Initialized.";\r
                context_.execution().begin_invoke([this]{tick();});\r
index a25ab8baf7793ca49a88b87a719f476bb9554c9f..714d2e575583659e25c7a646ff90d2b33179f690 100644 (file)
@@ -310,22 +310,44 @@ struct bluefish_consumer_proxy : public core::frame_consumer
        const size_t                                            device_index_;\r
        const bool                                                      embedded_audio_;\r
        const bool                                                      key_only_;\r
+       core::video_format_desc                         format_desc_;\r
+       size_t                                                          fail_count_;\r
 public:\r
 \r
        bluefish_consumer_proxy(size_t device_index, bool embedded_audio, bool key_only)\r
                : device_index_(device_index)\r
                , embedded_audio_(embedded_audio)\r
-               , key_only_(key_only){}\r
+               , key_only_(key_only)\r
+               , fail_count_(0)\r
+       {\r
+       }\r
        \r
        virtual void initialize(const core::video_format_desc& format_desc)\r
        {\r
-               consumer_.reset();\r
+               format_desc_ = format_desc;\r
                consumer_.reset(new bluefish_consumer(format_desc, device_index_, embedded_audio_));\r
        }\r
        \r
        virtual bool send(const safe_ptr<core::read_frame>& frame)\r
        {\r
-               consumer_->send(frame);\r
+               if(!consumer_)\r
+                       consumer_.reset(new bluefish_consumer(format_desc_, device_index_, embedded_audio_));\r
+\r
+               try\r
+               {\r
+                       consumer_->send(frame);\r
+                       fail_count_ = 0;\r
+               }\r
+               catch(...)\r
+               {\r
+                       consumer_.reset();\r
+\r
+                       if(fail_count_++ > 3)\r
+                               return false;  // Outside didn't handle exception properly, just give up.\r
+\r
+                       throw;\r
+               }\r
+\r
                return true;\r
        }\r
 \r
index b3a9400e9a18d594f30fc0a088a331f731552f64..408a283ad40c3b57a0746bdeafcd6a48192fcf17 100644 (file)
@@ -293,7 +293,7 @@ public:
 \r
                        std::shared_ptr<core::read_frame> frame;        \r
                        video_frame_buffer_.pop(frame);                                 \r
-                       schedule_next_video(make_safe(frame));                  \r
+                       schedule_next_video(make_safe(frame));  \r
                }\r
                catch(...)\r
                {\r
@@ -383,23 +383,45 @@ public:
 \r
 struct decklink_consumer_proxy : public core::frame_consumer\r
 {\r
-       const configuration config_;\r
-\r
-       com_context<decklink_consumer> context_;\r
+       const configuration                             config_;\r
+       com_context<decklink_consumer>  context_;\r
+       core::video_format_desc                 format_desc_;\r
+       size_t                                                  fail_count_;\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
+               , context_(L"decklink_consumer[" + boost::lexical_cast<std::wstring>(config.device_index) + L"]")\r
+               , fail_count_(0)\r
+       {\r
+       }\r
        \r
        virtual void initialize(const core::video_format_desc& format_desc)\r
        {\r
-               context_.reset([&]{return new decklink_consumer(config_, format_desc);});\r
+               format_desc_ = format_desc;\r
+               context_.reset([&]{return new decklink_consumer(config_, format_desc_);});\r
        }\r
        \r
        virtual bool send(const safe_ptr<core::read_frame>& frame)\r
        {\r
-               context_->send(frame);\r
+               if(!context_)\r
+                       context_.reset([&]{return new decklink_consumer(config_, format_desc_);});\r
+\r
+               try\r
+               {\r
+                       context_->send(frame);\r
+                       fail_count_ = 0;\r
+               }\r
+               catch(...)\r
+               {\r
+                       context_.reset();\r
+\r
+                       if(fail_count_++ > 3)\r
+                               return false;  // Outside didn't handle exception properly, just give up.\r
+                       \r
+                       throw;\r
+               }\r
+\r
                return true;\r
        }\r
        \r
@@ -415,7 +437,7 @@ public:
                \r
        virtual const core::video_format_desc& get_video_format_desc() const\r
        {\r
-               return context_->get_video_format_desc();\r
+               return format_desc_;\r
        }\r
 };     \r
 \r
index 20d4ea53e32695fa56d8c345775fb06f98e18414..dc79cda0cfd2ad64e3630b078179b17a3ba95348 100644 (file)
@@ -46,7 +46,7 @@
   </producers>\r
   <channels>\r
     <channel>\r
-      <video-mode>1080p5000</video-mode>\r
+      <video-mode>1080i5000</video-mode>\r
       <consumers>\r
         <decklink>\r
           <device>1</device>\r
@@ -56,7 +56,7 @@
       </consumers>\r
     </channel>\r
     <channel>\r
-      <video-mode>1080p5000</video-mode>\r
+      <video-mode>1080i5000</video-mode>\r
       <consumers>\r
         <decklink>\r
           <device>2</device>\r