]> git.sesse.net Git - casparcg/commitdiff
2.0. ffmpeg_producer: Now runs in parallel with gpu mixer, instead of synchronously...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 26 Jun 2011 21:50:47 +0000 (21:50 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 26 Jun 2011 21:50:47 +0000 (21:50 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@956 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

modules/ffmpeg/producer/ffmpeg_producer.cpp

index 4d46513007aaadad47f28bb1997e559b62383389..325184f3826fe4997c7c2f9e8d154b563b14c353 100644 (file)
@@ -37,6 +37,7 @@
 #include <common/env.h>\r
 \r
 #include <tbb/parallel_invoke.h>\r
+#include <tbb/task_group.h>\r
 \r
 #include <boost/timer.hpp>\r
 #include <boost/range/algorithm.hpp>\r
@@ -61,6 +62,8 @@ struct ffmpeg_producer : public core::frame_producer
 \r
        std::deque<std::pair<int, std::vector<int16_t>>> audio_chunks_;\r
        std::deque<std::pair<int, safe_ptr<core::write_frame>>> video_frames_;\r
+       \r
+       tbb::task_group                                                 task_group_;\r
 public:\r
        explicit ffmpeg_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, const std::wstring& filter_str, bool loop, int start, int length) \r
                : filename_(filename)\r
@@ -175,8 +178,13 @@ public:
        }\r
 \r
        safe_ptr<core::basic_frame> decode_frame()\r
-       {\r
-               decode_packets();\r
+       {               \r
+               // "receive" is called on the same thread as the gpu mixer runs. Minimize "receive" time in order to allow gpu and cpu to run in parallel. \r
+               task_group_.wait();\r
+               task_group_.run([=]\r
+               {\r
+                       decode_packets();\r
+               });\r
 \r
                if(video_decoder_ && audio_decoder_ && !video_frames_.empty() && !audio_chunks_.empty())\r
                {\r