]> 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>
Fri, 28 Oct 2011 09:30:45 +0000 (09:30 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 28 Oct 2011 09:30:45 +0000 (09:30 +0000)
common/common.vcxproj
common/common.vcxproj.filters
common/concurrency/throw_away.h [new file with mode: 0644]
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/muxer/frame_muxer.cpp
modules/flash/producer/flash_producer.cpp

index 807ff5f93294aa92492481f9d7da5a34db9cf105..449d16135293ff56c6878c1b8197941a0551421b 100644 (file)
     <ClInclude Include="compiler\vs\disable_silly_warnings.h" />\r
     <ClInclude Include="concurrency\executor.h" />\r
     <ClInclude Include="concurrency\governor.h" />\r
+    <ClInclude Include="concurrency\throw_away.h" />\r
     <ClInclude Include="diagnostics\graph.h" />\r
     <ClInclude Include="exception\exceptions.h" />\r
     <ClInclude Include="exception\win32_exception.h" />\r
index 43c4f0eef2a11c5af7d4a65676bf0f3eadf3b1aa..8fe9e9872a65f2ffb0b8d13718698519d5647361 100644 (file)
     <ClInclude Include="concurrency\governor.h">\r
       <Filter>source\concurrency</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="concurrency\throw_away.h">\r
+      <Filter>source\concurrency</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
diff --git a/common/concurrency/throw_away.h b/common/concurrency/throw_away.h
new file mode 100644 (file)
index 0000000..6d2609a
--- /dev/null
@@ -0,0 +1,14 @@
+#pragma once\r
+\r
+#include <agents.h>\r
+\r
+namespace caspar {\r
+\r
+template<typename T>\r
+void link_throw_away(Concurrency::ISource<T>& source)\r
+{\r
+       static Concurrency::call<T> throw_away([](const T& elem){});\r
+       source.link_target(&throw_away);\r
+}\r
+\r
+}
\ No newline at end of file
index 1db34675b745c716e7a6e48716e72f35eff6504d..274e43134c6094a4883f6139944b47c6ca374927 100644 (file)
 #include "video/video_decoder.h"\r
 #include "../ffmpeg_error.h"\r
 \r
+#include <common/concurrency/throw_away.h>\r
 #include <common/env.h>\r
-#include <common/utility/assert.h>\r
 #include <common/diagnostics/graph.h>\r
+#include <common/utility/assert.h>\r
 \r
 #include <core/video_format.h>\r
 #include <core/producer/frame_producer.h>\r
@@ -63,8 +64,6 @@ struct ffmpeg_producer : public core::frame_producer
        const bool                                                                                                                              loop_;\r
        const size_t                                                                                                                    length_;\r
        \r
-       call<input::target_element_t>                                                                                   throw_away_packets_;\r
-       call<frame_muxer2::target_element_t>                                                                    throw_away_frames_;\r
        unbounded_buffer<input::target_element_t>                                                               packets_;\r
        std::shared_ptr<unbounded_buffer<frame_muxer2::video_source_element_t>> video_;\r
        std::shared_ptr<unbounded_buffer<frame_muxer2::audio_source_element_t>> audio_;\r
@@ -85,8 +84,6 @@ public:
                , start_(start)\r
                , loop_(loop)\r
                , length_(length)\r
-               , throw_away_packets_([](const input::target_element_t&){})\r
-               , throw_away_frames_([](const frame_muxer2::target_element_t&){})\r
                , input_(packets_, graph_, filename_, loop, start, length)\r
                , last_frame_(core::basic_frame::empty())\r
        {               \r
@@ -124,7 +121,7 @@ public:
 \r
                CASPAR_VERIFY(video_decoder_ || audio_decoder_, ffmpeg_error());\r
                \r
-               packets_.link_target(&throw_away_packets_);\r
+               link_throw_away(packets_);\r
                muxer_.reset(new frame_muxer2(video_.get(), audio_.get(), frames_, video_decoder_ ? video_decoder_->fps() : frame_factory->get_video_format_desc().fps, frame_factory));\r
                                \r
                graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));   \r
@@ -137,7 +134,7 @@ public:
        ~ffmpeg_producer()\r
        {\r
                input_.stop();  \r
-               frames_.link_target(&throw_away_frames_);\r
+               link_throw_away(frames_);\r
        }\r
                                                \r
        virtual safe_ptr<core::basic_frame> receive(int hints)\r
index 2db845dc40aec98c5a78571660ee23a76da80e23..bf623f23b91f7c423b9c7e399104e1f0db284c39 100644 (file)
@@ -96,11 +96,7 @@ struct frame_muxer2::implementation : public Concurrency::agent, boost::noncopya
                video = receive(video_source_);\r
                \r
                if(video == flush_video())\r
-               {\r
-                       if(filter_.has_value())\r
-                               filter_.value()->push(nullptr);\r
                        return receive_video();\r
-               }\r
 \r
                if(video == eof_video())\r
                        return nullptr;         \r
index bee63d72a2bf3325a8b1b47f21b8dfe4eac238d0..9bfb82af182884e38d502b6f4a12ab2e5227ea1d 100644 (file)
@@ -34,8 +34,9 @@
 #include <core/producer/frame/frame_factory.h>\r
 #include <core/mixer/write_frame.h>\r
 \r
-#include <common/env.h>\r
+#include <common/concurrency/throw_away.h>\r
 #include <common/diagnostics/graph.h>\r
+#include <common/env.h>\r
 #include <common/memory/memcpy.h>\r
 #include <common/memory/memclr.h>\r
 #include <common/utility/timer.h>\r
@@ -296,8 +297,7 @@ public:
        ~flash_producer()\r
        {\r
                is_running_ = false;\r
-               auto frame = core::basic_frame::empty();\r
-               while(try_receive(frames_, frame)){}\r
+               link_throw_away(frames_);\r
                agent::wait(this);\r
        }\r
        \r