Skip to content

Commit

Permalink
fix(ffmpeg): throttle buffering
Browse files Browse the repository at this point in the history
Former-commit-id: b047f47
  • Loading branch information
ronag committed Feb 21, 2018
1 parent a6b7aaf commit 7a43e53
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/modules/ffmpeg/producer/av_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,6 @@ struct AVProducer::Impl
break;
}

// TODO (fix) This gives assertion warnings.
//if (buffer_.size() > buffer_capacity_ / 2) {
// task_context_.set_priority(tbb::priority_low);
//} else if (buffer_.size() > 2) {
// task_context_.set_priority(tbb::priority_normal);
//} else {
// task_context_.set_priority(tbb::priority_high);
//}

caspar::timer frame_timer;
CASPAR_SCOPE_EXIT
{
Expand All @@ -521,6 +512,12 @@ struct AVProducer::Impl

std::unique_lock<std::mutex> lock(mutex_);

if (buffer_.size() > buffer_capacity_ / 2) {
cond_.wait_for(lock, 10ms, [&] { return abort_request_.load(); });
} else if (buffer_.size() > 2) {
cond_.wait_for(lock, 5ms, [&] { return abort_request_.load(); });
}

// TODO (perf) seek as soon as input is past duration or eof.
{
auto start = start_ != AV_NOPTS_VALUE ? start_ : 0;
Expand Down

0 comments on commit 7a43e53

Please sign in to comment.