]> 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>
Thu, 20 Oct 2011 10:52:56 +0000 (10:52 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 20 Oct 2011 10:52:56 +0000 (10:52 +0000)
modules/decklink/producer/decklink_producer.cpp
modules/ffmpeg/producer/filter/filter.cpp
modules/ffmpeg/producer/filter/filter.h
modules/ogl/consumer/ogl_consumer.cpp

index 34d8913fde9d1d830d359ca208c97c9793abcf25..10030b133dc153c81c3ab74412b13b1765515f26 100644 (file)
@@ -41,6 +41,7 @@
 \r
 #include <agents.h>\r
 #include <agents_extras.h>\r
+#include <ppl.h>\r
 \r
 #include <boost/algorithm/string.hpp>\r
 #include <boost/foreach.hpp>\r
@@ -279,23 +280,29 @@ public:
                                        \r
                                filter_.push(av_frame);\r
 \r
-                               while(true)\r
+                               Concurrency::parallel_invoke(\r
+                               [&]\r
                                {\r
-                                       auto frame = filter_.poll();\r
-                                       if(!frame)\r
-                                               break;\r
-                                       Concurrency::send<std::shared_ptr<AVFrame>>(*video_frames_, frame);\r
-                               }\r
-                                                                                                       \r
-                               // It is assumed that audio is always equal or ahead of video.\r
-                               if(audio && SUCCEEDED(audio->GetBytes(&bytes)))\r
-                               {\r
-                                       auto sample_frame_count = audio->GetSampleFrameCount();\r
-                                       auto audio_data = reinterpret_cast<int32_t*>(bytes);\r
-                                       Concurrency::send(*audio_buffers_, std::make_shared<core::audio_buffer>(audio_data, audio_data + sample_frame_count*format_desc_.audio_channels));\r
-                               }\r
-                               else\r
-                                       Concurrency::send(*audio_buffers_, ffmpeg::empty_audio());      \r
+                                       while(true)\r
+                                       {\r
+                                               auto frame = filter_.poll();\r
+                                               if(!frame)\r
+                                                       break;\r
+                                               Concurrency::send<std::shared_ptr<AVFrame>>(*video_frames_, frame);\r
+                                       }\r
+                               },\r
+                               [&]\r
+                               {                                                                                                       \r
+                                       // It is assumed that audio is always equal or ahead of video.\r
+                                       if(audio && SUCCEEDED(audio->GetBytes(&bytes)))\r
+                                       {\r
+                                               auto sample_frame_count = audio->GetSampleFrameCount();\r
+                                               auto audio_data = reinterpret_cast<int32_t*>(bytes);\r
+                                               Concurrency::send(*audio_buffers_, std::make_shared<core::audio_buffer>(audio_data, audio_data + sample_frame_count*format_desc_.audio_channels));\r
+                                       }\r
+                                       else\r
+                                               Concurrency::send(*audio_buffers_, ffmpeg::empty_audio());      \r
+                               });\r
                        }\r
 \r
                }\r
index 06ec5908bc812d114dad0e4a8c29cddace451aa6..5a1a5eec7a41ae2d97c69104bcd18e1399e65116 100644 (file)
@@ -175,5 +175,17 @@ filter::filter(filter&& other) : impl_(std::move(other.impl_)){}
 filter& filter::operator=(filter&& other){impl_ = std::move(other.impl_); return *this;}\r
 void filter::push(const std::shared_ptr<AVFrame>& frame){impl_->push(frame);}\r
 std::shared_ptr<AVFrame> filter::poll(){return impl_->poll();}\r
+std::vector<safe_ptr<AVFrame>> filter::poll_all()\r
+{      \r
+       std::vector<safe_ptr<AVFrame>> frames;\r
+       while(true)\r
+       {\r
+               auto frame = poll();\r
+               if(!frame)\r
+                       break;\r
+               frames.push_back(make_safe_ptr(frame));\r
+       }\r
+       return frames;\r
+}\r
 \r
 }}
\ No newline at end of file
index 37d8ccfe6a6f5d80084360a15af290846fd6e04c..434ee38c081c8b63cab68f838f033261c219176f 100644 (file)
@@ -32,7 +32,8 @@ public:
 \r
        void push(const std::shared_ptr<AVFrame>& frame);\r
        std::shared_ptr<AVFrame> poll();\r
-\r
+       std::vector<safe_ptr<AVFrame>> poll_all();\r
+       \r
 private:\r
        struct implementation;\r
        safe_ptr<implementation> impl_;\r
index d29e3bd6707fbd44f28371d6d3ac09b23aaa0c85..9ecddc83175237be642c56c14ec086af7c4ed844 100644 (file)
@@ -294,15 +294,7 @@ public:
                auto av_frame = get_av_frame();\r
                av_frame->data[0] = const_cast<uint8_t*>(frame->image_data().begin());\r
 \r
-               std::vector<safe_ptr<AVFrame>> frames;\r
-               filter_.push(av_frame);\r
-               while(true)\r
-               {\r
-                       auto frame = filter_.poll();\r
-                       if(!frame)\r
-                               break;\r
-                       frames.push_back(make_safe_ptr(frame));\r
-               }\r
+               auto frames = filter_.poll_all();\r
                \r
                if(frames.empty())\r
                        return;\r