class governor : boost::noncopyable\r
{\r
tbb::atomic<int> count_;\r
+ tbb::atomic<int> is_running_;\r
Concurrency::concurrent_queue<Concurrency::Context*> waiting_contexts_;\r
\r
void acquire_ticket()\r
{\r
+ if(!is_running_)\r
+ return;\r
+\r
if(count_ < 1)\r
Concurrency::Context::Yield();\r
\r
\r
void release_ticket()\r
{\r
+ if(!is_running_)\r
+ return;\r
+\r
if(++count_ <= 0)\r
{\r
Concurrency:: Context* waiting = NULL;\r
\r
governor(size_t capacity) \r
{\r
+ is_running_ = true;\r
count_ = capacity;\r
}\r
\r
\r
void cancel()\r
{\r
- while(count_ < 0)\r
- release_ticket();\r
+ is_running_ = false;\r
+ Concurrency::Context* waiting = NULL;\r
+ while(waiting_contexts_.try_pop(waiting))\r
+ waiting->Unblock();\r
}\r
};\r
\r
#include <boost/range/algorithm/find.hpp>\r
\r
#include <agents.h>\r
+#include <concrt.h>\r
\r
-#include <iterator>\r
#include <vector>\r
#include <string>\r
\r
const bool loop_;\r
const size_t length_;\r
\r
- call<input::target_element_t> throw_away_;\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
, start_(start)\r
, loop_(loop)\r
, length_(length)\r
- , throw_away_([](const input::target_element_t&){})\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
\r
CASPAR_VERIFY(video_decoder_ || audio_decoder_, ffmpeg_error());\r
\r
- packets_.link_target(&throw_away_);\r
+ packets_.link_target(&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
~ffmpeg_producer()\r
{\r
input_.stop(); \r
- while(Concurrency::receive(frames_).first != core::basic_frame::eof()){}\r
+ frames_.link_target(&throw_away_frames_);\r
}\r
\r
virtual safe_ptr<core::basic_frame> receive(int hints)\r