]> git.sesse.net Git - casparcg/commitdiff
2.0. flash_producer: Fixed invalid fields in last_frame.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 24 Aug 2011 11:30:50 +0000 (11:30 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 24 Aug 2011 11:30:50 +0000 (11:30 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1272 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/mixer/image/image_mixer.cpp
modules/flash/producer/flash_producer.cpp

index 88c2e177d0ba7221cbef8c11942073cbae4ad401..2b6769d792f319cf50f5c55537e5924327883187 100644 (file)
@@ -100,7 +100,7 @@ private:
                if(layer.empty())\r
                        return;\r
 \r
-               std::pair<int, std::shared_ptr<device_buffer>> local_key_buffer; // int is fields flag\r
+               std::pair<int, std::shared_ptr<device_buffer>> local_key_buffer = std::make_pair(0, nullptr); // int is fields flag\r
                                \r
                if(layer.front().blend_mode != blend_mode::normal && has_overlapping_items(layer))\r
                {\r
index da4572f7efa547b8de360dec4b9c04a281a4539e..c285ba9fcc876ab55a9843bed79fa7e899958dda 100644 (file)
@@ -47,6 +47,8 @@
 \r
 #include <functional>\r
 \r
+#include <tbb/spin_mutex.h>\r
+\r
 namespace caspar {\r
                \r
 class bitmap\r
@@ -157,7 +159,7 @@ public:
                graph_->add_guide("tick-time", 0.5);\r
                graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f));\r
                graph_->set_color("param", diagnostics::color(1.0f, 0.5f, 0.0f));       \r
-               graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));                   \r
+               graph_->set_color("skip-sync", diagnostics::color(0.8f, 0.3f, 0.2f));                   \r
                \r
                if(FAILED(CComObject<caspar::flash::FlashAxContainer>::CreateInstance(&ax_)))\r
                        BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to create FlashAxContainer"));\r
@@ -216,7 +218,7 @@ public:
                if(!has_underflow)                      \r
                        timer_.tick(frame_time); // This will block the thread.\r
                else\r
-                       graph_->add_tag("underflow");\r
+                       graph_->add_tag("skip-sync");\r
                        \r
                frame_timer_.restart();\r
 \r
@@ -258,6 +260,7 @@ struct flash_producer : public core::frame_producer
 \r
        tbb::concurrent_bounded_queue<safe_ptr<core::basic_frame>> frame_buffer_;\r
 \r
+       mutable tbb::spin_mutex         last_frame_mutex_;\r
        safe_ptr<core::basic_frame>     last_frame_;\r
                                \r
        com_context<flash_renderer> context_;   \r
@@ -275,11 +278,12 @@ public:
        {       \r
                if(!boost::filesystem::exists(filename))\r
                        BOOST_THROW_EXCEPTION(file_not_found() << boost::errinfo_file_name(narrow(filename)));  \r
-                \r
+\r
                fps_ = 0;\r
 \r
                graph_ = diagnostics::create_graph([this]{return print();});\r
-               graph_->set_color("output-buffer-count", diagnostics::color(1.0f, 1.0f, 0.0f));\r
+               graph_->set_color("output-buffer-count", diagnostics::color(1.0f, 1.0f, 0.0f));          \r
+               graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));   \r
                \r
                frame_buffer_.set_capacity(frame_factory_->get_video_format_desc().fps > 30.0 ? 2 : 1);\r
 \r
@@ -298,14 +302,15 @@ public:
                graph_->set_value("output-buffer-count", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity()));\r
 \r
                auto frame = core::basic_frame::late();\r
-               if(frame_buffer_.try_pop(frame))\r
-                       last_frame_ = frame;\r
+               if(!frame_buffer_.try_pop(frame))\r
+                       graph_->add_tag("underflow");\r
 \r
                return frame;\r
        }\r
 \r
        virtual safe_ptr<core::basic_frame> last_frame() const\r
        {\r
+               tbb::spin_mutex::scoped_lock lock(last_frame_mutex_);\r
                return last_frame_;\r
        }               \r
        \r
@@ -347,6 +352,14 @@ public:
                render(context_.get());\r
        }\r
 \r
+       safe_ptr<core::basic_frame> render_frame()\r
+       {\r
+               auto frame = context_->render_frame(frame_buffer_.size() < frame_buffer_.capacity());           \r
+               tbb::spin_mutex::scoped_lock lock(last_frame_mutex_);\r
+               last_frame_ = make_safe<core::basic_frame>(frame);\r
+               return frame;\r
+       }\r
+\r
        void render(const flash_renderer* renderer)\r
        {               \r
                context_.begin_invoke([=]\r
@@ -360,19 +373,19 @@ public:
 \r
                                if(abs(context_->fps()/2.0 - format_desc.fps) < 2.0) // flash == 2 * format -> interlace\r
                                {\r
-                                       auto frame1 = context_->render_frame(frame_buffer_.size() < frame_buffer_.capacity());\r
-                                       auto frame2 = context_->render_frame(frame_buffer_.size() < frame_buffer_.capacity());\r
+                                       auto frame1 = render_frame();\r
+                                       auto frame2 = render_frame();\r
                                        frame_buffer_.push(core::basic_frame::interlace(frame1, frame2, format_desc.field_mode));\r
                                }\r
                                else if(abs(context_->fps()- format_desc.fps/2.0) < 2.0) // format == 2 * flash -> duplicate\r
                                {\r
-                                       auto frame = context_->render_frame(frame_buffer_.size() < frame_buffer_.capacity());\r
+                                       auto frame = render_frame();\r
                                        frame_buffer_.push(frame);\r
                                        frame_buffer_.push(frame);\r
                                }\r
                                else //if(abs(renderer_->fps() - format_desc_.fps) < 0.1) // format == flash -> simple\r
                                {\r
-                                       auto frame = context_->render_frame(frame_buffer_.size() < frame_buffer_.capacity());\r
+                                       auto frame = render_frame();\r
                                        frame_buffer_.push(frame);\r
                                }\r
 \r