]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 17 Aug 2011 09:05:34 +0000 (09:05 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 17 Aug 2011 09:05:34 +0000 (09:05 +0000)
modules/flash/producer/flash_producer.cpp

index 41af75693f51643b1ec05da637bd54e96804e5b1..e9f81c795ff18a2ee0fa3a0bfe6e8ab739fd126a 100644 (file)
@@ -286,11 +286,8 @@ public:
                graph_ = diagnostics::create_graph([this]{return print();});\r
                graph_->set_color("buffer-count", diagnostics::color(0.4f, 0.8f, 0.8f));\r
                                \r
-               frame_buffer_.set_capacity(1);\r
-               \r
-               context_.reset([&]{return new flash_renderer(safe_ptr<diagnostics::graph>(graph_), frame_factory_, filename_, width_, height_);});\r
-               while(frame_buffer_.try_push(core::basic_frame::empty())){}             \r
-               render();                       \r
+               frame_buffer_.set_capacity(1);          \r
+               initialize();\r
        }\r
 \r
        ~flash_producer()\r
@@ -298,6 +295,14 @@ public:
                frame_buffer_.clear();\r
        }\r
 \r
+       void initialize()\r
+       {               \r
+               context_.reset(nullptr);\r
+               context_.reset([&]{return new flash_renderer(safe_ptr<diagnostics::graph>(graph_), frame_factory_, filename_, width_, height_);});\r
+               while(frame_buffer_.try_push(core::basic_frame::empty())){}             \r
+               render();       \r
+       }\r
+\r
        // frame_producer\r
                \r
        virtual safe_ptr<core::basic_frame> receive(int)\r
@@ -335,19 +340,31 @@ public:
                        try\r
                        {\r
                                context_->param(param); \r
-\r
-                               const auto& format_desc = frame_factory_->get_video_format_desc();\r
-                               if(abs(context_->fps() - format_desc.fps) > 2.0 && abs(context_->fps()/2.0 - format_desc.fps) > 2.0)\r
-                                       CASPAR_LOG(warning) << print() << " Invalid frame-rate: " << context_->fps() << L". Should be either " << format_desc.fps << L" or " << format_desc.fps*2.0 << L".";\r
                        }\r
                        catch(...)\r
                        {\r
-                               CASPAR_LOG_CURRENT_EXCEPTION();\r
-                               context_.reset(nullptr);\r
+                               try\r
+                               {\r
+                                       CASPAR_LOG_CURRENT_EXCEPTION();\r
+                                       CASPAR_LOG(error) << print() << L" param failed. Trying to re-initialize flash and re-execute param.";\r
 \r
-                               tbb::spin_mutex::scoped_lock lock(exception_mutex_);\r
-                               exception_ = std::current_exception();\r
+                                       initialize();                           \r
+                                       context_->param(param); \r
+                               }\r
+                               catch(...)\r
+                               {\r
+                                       CASPAR_LOG_CURRENT_EXCEPTION();\r
+\r
+                                       context_.reset(nullptr);\r
+\r
+                                       tbb::spin_mutex::scoped_lock lock(exception_mutex_);\r
+                                       exception_ = std::current_exception();\r
+                               }\r
                        }\r
+\r
+                       const auto& format_desc = frame_factory_->get_video_format_desc();\r
+                       if(abs(context_->fps() - format_desc.fps) > 2.0 && abs(context_->fps()/2.0 - format_desc.fps) > 2.0)\r
+                               CASPAR_LOG(warning) << print() << " Invalid frame-rate: " << context_->fps() << L". Should be either " << format_desc.fps << L" or " << format_desc.fps*2.0 << L".";\r
                });\r
        }\r
                \r