const std::string name_;
boost::thread thread_;
tbb::atomic<bool> is_running_;
+ tbb::atomic<bool> execute_rest_;
typedef tbb::concurrent_bounded_queue<std::function<void()>> function_queue;
function_queue execution_queue_[priority_count];
void stop() // noexcept
{
+ execute_rest_ = false;
is_running_ = false;
execution_queue_[normal_priority].try_push([]{}); // Wake the execution thread.
}
+
+ void stop_execute_rest() // noexcept
+ {
+ execute_rest_ = true;
+ is_running_ = false;
+ execution_queue_[normal_priority].try_push([]{}); // Wake the execution thread.
+ }
void wait() // noexcept
{
func();
}
+ void execute_rest(task_priority priority) // noexcept
+ {
+ std::function<void()> func;
+
+ while (execution_queue_[priority].try_pop(func))
+ if (func)
+ func();
+ }
+
void run() // noexcept
{
win32_exception::install_handler();
CASPAR_LOG_CURRENT_EXCEPTION();
}
}
+
+ if (execute_rest_)
+ {
+ execute_rest(high_priority);
+ execute_rest(normal_priority);
+ }
}
};
\r
~ffmpeg_consumer()\r
{ \r
- encode_executor_.stop();\r
+ encode_executor_.stop_execute_rest();\r
encode_executor_.join();\r
+\r
+ // Flush\r
+ LOG_ON_ERROR2(av_interleaved_write_frame(oc_.get(), nullptr), "[ffmpeg_consumer]");\r
\r
LOG_ON_ERROR2(av_write_trailer(oc_.get()), "[ffmpeg_consumer]");\r
\r