From: Carl Hetherington Date: Tue, 18 Jul 2017 15:06:14 +0000 (+0100) Subject: Don't set up Writer etc. until the job is run. This means that X-Git-Tag: v2.11.14~3 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=2d57296a24c2eb4f6d99325add0e986de04f7e7d;p=dcpomatic.git Don't set up Writer etc. until the job is run. This means that jobs queued in the batch converter don't start too early; e.g. if you add the same job twice the check of the existing video won't start on the second job until the first is complete. --- diff --git a/src/lib/dcp_encoder.cc b/src/lib/dcp_encoder.cc index a37080405..67235e596 100644 --- a/src/lib/dcp_encoder.cc +++ b/src/lib/dcp_encoder.cc @@ -56,12 +56,12 @@ using boost::dynamic_pointer_cast; */ DCPEncoder::DCPEncoder (shared_ptr film, weak_ptr job) : Encoder (film, job) - , _writer (new Writer (film, job)) - , _j2k_encoder (new J2KEncoder (film, _writer)) + , _film (film) + , _job (job) , _finishing (false) , _non_burnt_subtitles (false) { - BOOST_FOREACH (shared_ptr c, _film->content ()) { + BOOST_FOREACH (shared_ptr c, film->content ()) { if (c->subtitle && c->subtitle->use() && !c->subtitle->burn()) { _non_burnt_subtitles = true; } @@ -79,7 +79,10 @@ DCPEncoder::~DCPEncoder () void DCPEncoder::go () { + _writer.reset (new Writer (_film, _job)); _writer->start (); + + _j2k_encoder.reset (new J2KEncoder (_film, _writer)); _j2k_encoder->begin (); { @@ -135,11 +138,19 @@ DCPEncoder::subtitle (PlayerSubtitles data, DCPTimePeriod period) float DCPEncoder::current_rate () const { + if (!_j2k_encoder) { + return 0; + } + return _j2k_encoder->current_encoding_rate (); } Frame DCPEncoder::frames_done () const { + if (!_j2k_encoder) { + return 0; + } + return _j2k_encoder->video_frames_enqueued (); } diff --git a/src/lib/dcp_encoder.h b/src/lib/dcp_encoder.h index d35b06184..b1514efdc 100644 --- a/src/lib/dcp_encoder.h +++ b/src/lib/dcp_encoder.h @@ -54,6 +54,8 @@ private: void audio (boost::shared_ptr, DCPTime); void subtitle (PlayerSubtitles, DCPTimePeriod); + boost::shared_ptr _film; + boost::weak_ptr _job; boost::shared_ptr _writer; boost::shared_ptr _j2k_encoder; bool _finishing;