graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));\r
graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f));\r
graph_->set_color("param", diagnostics::color(1.0f, 0.5f, 0.0f)); \r
- graph_->set_color("skip-sync", diagnostics::color(0.8f, 0.3f, 0.2f)); \r
+ graph_->set_color("sync", diagnostics::color(0.8f, 0.3f, 0.2f)); \r
\r
if(FAILED(CComObject<caspar::flash::FlashAxContainer>::CreateInstance(&ax_)))\r
BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to create FlashAxContainer"));\r
return result;\r
}\r
\r
- safe_ptr<core::basic_frame> render_frame(bool sync)\r
+ safe_ptr<core::basic_frame> render_frame(double sync)\r
{\r
float frame_time = 1.0f/ax_->GetFPS();\r
\r
if(ax_->IsEmpty())\r
return core::basic_frame::empty(); \r
\r
- if(sync) \r
- timer_.tick(frame_time); // This will block the thread.\r
+ if(sync > 0.00001) \r
+ timer_.tick(frame_time*sync); // This will block the thread.\r
else\r
- graph_->set_tag("skip-sync");\r
+ graph_->set_tag("sync");\r
+\r
+ graph_->set_value("sync", sync);\r
\r
frame_timer_.restart();\r
\r
const int buffer_size_;\r
\r
tbb::atomic<int> fps_;\r
- tbb::atomic<bool> sync_;\r
\r
safe_ptr<diagnostics::graph> graph_;\r
\r
, buffer_size_(env::properties().get(L"configuration.flash.buffer-depth", frame_factory_->get_video_format_desc().fps > 30.0 ? 4 : 2))\r
, executor_(L"flash_producer")\r
{ \r
- sync_ = true;\r
fps_ = 0;\r
\r
- graph_->set_color("buffer-size", diagnostics::color(1.0f, 1.0f, 0.0f));\r
graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.9f));\r
graph_->set_text(print());\r
diagnostics::register_graph(graph_);\r
{ \r
auto frame = core::basic_frame::late();\r
\r
- graph_->set_value("buffer-size", static_cast<float>(output_buffer_.size())/static_cast<float>(buffer_size_));\r
- sync_ = output_buffer_.size() == buffer_size_;\r
-\r
if(output_buffer_.try_pop(frame)) \r
next();\r
else\r
\r
safe_ptr<core::basic_frame> render_frame()\r
{ \r
- auto frame = renderer_->render_frame(sync_);\r
+ double ratio = std::min(1.0, static_cast<double>(output_buffer_.size())/static_cast<double>(std::max(1, buffer_size_ - 1)));\r
+ double sync = 2*ratio - ratio*ratio;\r
+\r
+ auto frame = renderer_->render_frame(sync);\r
lock(last_frame_mutex_, [&]\r
{\r
last_frame_ = frame;\r