]> git.sesse.net Git - casparcg/commitdiff
2.0. Improved error recovery.
authorRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 17:51:47 +0000 (17:51 +0000)
committerRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 17:51:47 +0000 (17:51 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1172 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/consumer/output.cpp
core/video_channel.cpp

index 3962adb4f8cc60a84afc38a9ff363051991634cc..51b62e57620c5d41238f6fafc2135280b7eb9358 100644 (file)
@@ -113,46 +113,40 @@ public:
        }\r
                                                \r
        void execute(const safe_ptr<read_frame>& frame)\r
-       {               \r
-               try\r
-               {               \r
-                       if(!has_synchronization_clock())\r
-                               timer_.tick(1.0/channel_.get_format_desc().fps);\r
-                                               \r
-                       auto fill = frame;\r
-                       auto key = make_safe<deferred_key_read_Frame>(channel_.ogl(), frame);\r
+       {                       \r
+               if(!has_synchronization_clock())\r
+                       timer_.tick(1.0/channel_.get_format_desc().fps);\r
 \r
-                       auto it = consumers_.begin();\r
-                       while(it != consumers_.end())\r
+               if(frame->image_size() != channel_.get_format_desc().size)\r
+               {\r
+                       timer_.tick(1.0/channel_.get_format_desc().fps);\r
+                       return;\r
+               }\r
+\r
+               auto fill = frame;\r
+               auto key = make_safe<deferred_key_read_Frame>(channel_.ogl(), frame);\r
+\r
+               auto it = consumers_.begin();\r
+               while(it != consumers_.end())\r
+               {\r
+                       try\r
                        {\r
-                               try\r
-                               {\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
-\r
-                                       auto frame = consumer->key_only() ? key : fill;\r
-\r
-                                       if(frame->image_size() == consumer->get_video_format_desc().size)\r
-                                       {       \r
-                                               if(!consumer->send(frame))\r
-                                                       consumers_.erase(it++);\r
-                                               else\r
-                                                       ++it;\r
-                                       }\r
-                               }\r
-                               catch(...)\r
-                               {\r
-                                       CASPAR_LOG_CURRENT_EXCEPTION();\r
-                                       CASPAR_LOG(error) << print() << L" " << it->second->print() << L" Removed.";\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
+\r
+                               if(consumer->send(consumer->key_only() ? key : fill))\r
+                                       ++it;\r
+                               else\r
                                        consumers_.erase(it++);\r
-                               }\r
                        }\r
-               }\r
-               catch(...)\r
-               {\r
-                       CASPAR_LOG_CURRENT_EXCEPTION();\r
+                       catch(...)\r
+                       {\r
+                               CASPAR_LOG_CURRENT_EXCEPTION();\r
+                               CASPAR_LOG(error) << print() << L" " << it->second->print() << L" Removed.";\r
+                               consumers_.erase(it++);\r
+                       }\r
                }\r
        }\r
 \r
index 23c1f16e4b0a471e54b7688b371dd26bb9089c0e..3519e2f3c5836179ce1f4d9499fcbd8d48214847 100644 (file)
@@ -44,9 +44,9 @@ struct video_channel::implementation : boost::noncopyable
 {\r
        video_channel_context                   context_;\r
 \r
-       safe_ptr<caspar::core::output>  output_;\r
-       safe_ptr<caspar::core::mixer>   mixer_;\r
-       safe_ptr<caspar::core::stage>   stage_;\r
+       safe_ptr<caspar::core::output>                  output_;\r
+       std::shared_ptr<caspar::core::mixer>    mixer_;\r
+       safe_ptr<caspar::core::stage>                   stage_;\r
 \r
        safe_ptr<diagnostics::graph>    diag_;\r
        boost::timer                                    frame_timer_;\r
@@ -116,9 +116,12 @@ public:
                {\r
                        CASPAR_LOG_CURRENT_EXCEPTION();\r
                        CASPAR_LOG(error) << context_.print() << L" Unexpected exception. Clearing stage and freeing memory";\r
+\r
                        stage_->clear();\r
                        context_.ogl().gc().wait();\r
-                       mixer_ = make_safe<caspar::core::mixer>(context_);\r
+\r
+                       mixer_ = nullptr;\r
+                       mixer_.reset(new caspar::core::mixer(context_));\r
                }\r
 \r
                context_.execution().begin_invoke([this]{tick();});\r
@@ -142,7 +145,7 @@ public:
 video_channel::video_channel(int index, const video_format_desc& format_desc, ogl_device& ogl) : impl_(new implementation(index, format_desc, ogl)){}\r
 video_channel::video_channel(video_channel&& other) : impl_(std::move(other.impl_)){}\r
 safe_ptr<stage> video_channel::stage() { return impl_->stage_;} \r
-safe_ptr<mixer> video_channel::mixer() { return impl_->mixer_;} \r
+safe_ptr<mixer> video_channel::mixer() { return make_safe(impl_->mixer_);} \r
 safe_ptr<output> video_channel::output() { return impl_->output_;} \r
 video_format_desc video_channel::get_video_format_desc() const{return impl_->context_.get_format_desc();}\r
 void video_channel::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}\r