]> git.sesse.net Git - casparcg/blobdiff - modules/flash/producer/flash_producer.cpp
2.0.2: Destroy flash on "isEmpty".
[casparcg] / modules / flash / producer / flash_producer.cpp
index c285ba9fcc876ab55a9843bed79fa7e899958dda..a93e70f08784c6e5efc6f081e67b715a30bc0e8a 100644 (file)
@@ -49,7 +49,7 @@
 \r
 #include <tbb/spin_mutex.h>\r
 \r
-namespace caspar {\r
+namespace caspar { namespace flash {\r
                \r
 class bitmap\r
 {\r
@@ -238,6 +238,11 @@ public:
                return head_;\r
        }\r
 \r
+       bool is_empty() const\r
+       {\r
+               return ax_->IsEmpty();\r
+       }\r
+\r
        double fps() const\r
        {\r
                return ax_->GetFPS();   \r
@@ -281,7 +286,7 @@ public:
 \r
                fps_ = 0;\r
 \r
-               graph_ = diagnostics::create_graph([this]{return print();});\r
+               graph_ = diagnostics::create_graph(narrow(print()));\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
@@ -302,7 +307,7 @@ 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
+               if(!frame_buffer_.try_pop(frame) && context_)\r
                        graph_->add_tag("underflow");\r
 \r
                return frame;\r
@@ -389,8 +394,15 @@ public:
                                        frame_buffer_.push(frame);\r
                                }\r
 \r
+                               if(context_->is_empty())\r
+                               {\r
+                                       context_.reset(nullptr);\r
+                                       return;\r
+                               }\r
+\r
                                graph_->set_value("output-buffer-count", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity()));        \r
-                               fps_.fetch_and_store(static_cast<int>(context_->fps()*100.0));\r
+                               fps_.fetch_and_store(static_cast<int>(context_->fps()*100.0));                          \r
+                               graph_->update_text(narrow(print()));\r
 \r
                                render(renderer);\r
                        }\r
@@ -404,14 +416,14 @@ public:
        }\r
 };\r
 \r
-safe_ptr<core::frame_producer> create_flash_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
+safe_ptr<core::frame_producer> create_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
 {\r
        auto template_host = get_template_host(frame_factory->get_video_format_desc());\r
        \r
        return make_safe<flash_producer>(frame_factory, env::template_folder() + L"\\" + widen(template_host.filename), template_host.width, template_host.height);\r
 }\r
 \r
-std::wstring find_flash_template(const std::wstring& template_name)\r
+std::wstring find_template(const std::wstring& template_name)\r
 {\r
        if(boost::filesystem::exists(template_name + L".ft")) \r
                return template_name + L".ft";\r
@@ -422,4 +434,4 @@ std::wstring find_flash_template(const std::wstring& template_name)
        return L"";\r
 }\r
 \r
-}
\ No newline at end of file
+}}
\ No newline at end of file