]> git.sesse.net Git - casparcg/commitdiff
Manually merged f669fb3d7a3be5d8e14777531489285dd0d836c4 from master
authorHelge Norberg <helge.norberg@svt.se>
Tue, 9 Apr 2013 15:17:14 +0000 (17:17 +0200)
committerHelge Norberg <helge.norberg@svt.se>
Tue, 9 Apr 2013 15:17:14 +0000 (17:17 +0200)
common/blocking_priority_queue.h
common/executor.h
modules/ffmpeg/consumer/ffmpeg_consumer.cpp

index f8cd0198cb4441a2cafb9e8439c039197c2a3cd2..efa6a711fc5f574261222ea6c091a24d694f9c1d 100644 (file)
@@ -56,7 +56,7 @@ public:
         * Constructor.
         *
         * @param capacity   The initial capacity of the queue.
-        * @param priorities A forward iterable container with the priorities to 
+        * @param priorities A forward iterable range with the priorities to 
         *                   support.
         */
        template<class PrioList>
@@ -227,6 +227,15 @@ public:
        {
                return elements_available_.permits();
        }
+
+       /**
+        * @return the current available space in the queue (may have changed at
+        *         the time of returning).
+        */
+       size_type space_available() const
+       {
+               return space_available_.permits();
+       }
 private:
        void push_acquired(Prio priority, const T& element, acquire_transaction& transaction)
        {
index 0e4c021e7c87b89f38a9e55518a2c2d78db2bbfb..7f781cc64540688e95dcd63554443d5cd8174278 100644 (file)
@@ -135,6 +135,11 @@ public:
        {
                return execution_queue_.capacity();
        }
+
+       bool is_full() const
+       {
+               return execution_queue_.space_available() == 0;
+       }
        
        void clear()
        {               
index 243c0bf9e54d95f8843a18c8dd5a2cf8ee8170f6..c26306fb02b16c68fc43dc6f8710dc8fda1fb2d8 100644 (file)
@@ -36,6 +36,7 @@
 #include <common/env.h>
 #include <common/except.h>
 #include <common/executor.h>
+#include <common/future.h>
 #include <common/diagnostics/graph.h>
 #include <common/lock.h>
 #include <common/memory.h>
@@ -293,6 +294,7 @@ public:
                boost::filesystem::remove(boost::filesystem::path(env::media_folder() + u16(filename))); // Delete the file if it exists
 
                graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));
+               graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f));
                graph_->set_text(print());
                diagnostics::register_graph(graph_);
 
@@ -356,13 +358,20 @@ public:
 
                if(exception != nullptr)
                        std::rethrow_exception(exception);
-                       
-               return executor_.begin_invoke([=]() -> bool
+
+               if (executor_.is_full())
+               {
+                       graph_->set_tag("dropped-frame");
+
+                       return wrap_as_future(true);
+               }
+
+               executor_.begin_invoke([=]
                {               
                        encode(frame);
-
-                       return true;
                });
+
+               return wrap_as_future(true);
        }
 
        std::wstring print() const