X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fwriter.cc;h=ca9b63df42db31eceeb4a9a105786fd12efbc135;hb=15f23b356b757a9697bf1a9ec30c243ab8070404;hp=580dfe4f21d19e0bfb452a37d32e413ad247d6b5;hpb=0da7c88a1afb221f97e2e96c159b1a984e4e2f71;p=dcpomatic.git diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 580dfe4f2..ca9b63df4 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -34,7 +34,7 @@ #include "film.h" #include "ratio.h" #include "log.h" -#include "dcp_video_frame.h" +#include "dcp_video.h" #include "dcp_content_type.h" #include "player.h" #include "audio_mapping.h" @@ -139,6 +139,7 @@ Writer::write (shared_ptr encoded, int frame, Eyes eyes) boost::mutex::scoped_lock lock (_mutex); while (_queued_full_in_memory > _maximum_frames_in_memory) { + /* The queue is too big; wait until that is sorted out */ _full_condition.wait (lock); } @@ -160,7 +161,8 @@ Writer::write (shared_ptr encoded, int frame, Eyes eyes) _queue.push_back (qi); ++_queued_full_in_memory; } - + + /* Now there's something to do: wake anything wait()ing on _empty_condition */ _empty_condition.notify_all (); } @@ -170,6 +172,7 @@ Writer::fake_write (int frame, Eyes eyes) boost::mutex::scoped_lock lock (_mutex); while (_queued_full_in_memory > _maximum_frames_in_memory) { + /* The queue is too big; wait until that is sorted out */ _full_condition.wait (lock); } @@ -191,6 +194,7 @@ Writer::fake_write (int frame, Eyes eyes) _queue.push_back (qi); } + /* Now there's something to do: wake anything wait()ing on _empty_condition */ _empty_condition.notify_all (); } @@ -237,16 +241,18 @@ void Writer::thread () try { - while (1) + while (true) { boost::mutex::scoped_lock lock (_mutex); - while (1) { + while (true) { if (_finish || _queued_full_in_memory > _maximum_frames_in_memory || have_sequenced_image_at_queue_head ()) { + /* We've got something to do: go and do it */ break; } + /* Nothing to do: wait until something happens which may indicate that we do */ LOG_TIMING (N_("writer sleeps with a queue of %1"), _queue.size()); _empty_condition.wait (lock); LOG_TIMING (N_("writer wakes with a queue of %1"), _queue.size()); @@ -336,6 +342,7 @@ try --_queued_full_in_memory; } + /* The queue has probably just gone down a bit; notify anything wait()ing on _full_condition */ _full_condition.notify_all (); } } @@ -523,7 +530,7 @@ Writer::check_existing_picture_mxf () ++N; } - while (1) { + while (true) { shared_ptr job = _job.lock (); assert (job);