summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-04-20 19:52:44 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-21 00:52:07 +0200
commite4b693f2e7b7dc2afb4e9ec3e96e317fff851c5b (patch)
treeabc8b867c43cf144cf7768c2ad9b9381be3ccde7
parent7021315442ab706ff497d574edb19831028ec8bd (diff)
Move digest calculation to a separate method.
-rw-r--r--src/lib/writer.cc69
-rw-r--r--src/lib/writer.h1
2 files changed, 40 insertions, 30 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 7208402e4..8fa9fbbca 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -535,36 +535,9 @@ Writer::terminate_thread (bool can_throw)
}
-/** @param output_dcp Path to DCP folder to write */
void
-Writer::finish (boost::filesystem::path output_dcp)
+Writer::calculate_digests ()
{
- if (_thread.joinable()) {
- LOG_GENERAL_NC ("Terminating writer thread");
- terminate_thread (true);
- }
-
- LOG_GENERAL_NC ("Finishing ReelWriters");
-
- for (auto& i: _reels) {
- write_hanging_text (i);
- i.finish (output_dcp);
- }
-
- LOG_GENERAL_NC ("Writing XML");
-
- dcp::DCP dcp (output_dcp);
-
- auto cpl = make_shared<dcp::CPL>(
- film()->dcp_name(),
- film()->dcp_content_type()->libdcp_kind(),
- film()->interop() ? dcp::Standard::INTEROP : dcp::Standard::SMPTE
- );
-
- dcp.add (cpl);
-
- /* Calculate digests for each reel in parallel */
-
auto job = _job.lock ();
if (job) {
job->sub (_("Computing digests"));
@@ -575,7 +548,7 @@ Writer::finish (boost::filesystem::path output_dcp)
auto work = make_shared<boost::asio::io_service::work>(service);
- int const threads = max (1, Config::instance()->master_encoding_threads ());
+ int const threads = max (1, Config::instance()->master_encoding_threads());
for (int i = 0; i < threads; ++i) {
pool.create_thread (boost::bind (&boost::asio::io_service::run, &service));
@@ -594,8 +567,44 @@ Writer::finish (boost::filesystem::path output_dcp)
service.post (boost::bind (&Writer::calculate_referenced_digests, this, set_progress));
work.reset ();
- pool.join_all ();
+
+ {
+ pool.join_all ();
+ }
+
service.stop ();
+}
+
+
+/** @param output_dcp Path to DCP folder to write */
+void
+Writer::finish (boost::filesystem::path output_dcp)
+{
+ if (_thread.joinable()) {
+ LOG_GENERAL_NC ("Terminating writer thread");
+ terminate_thread (true);
+ }
+
+ LOG_GENERAL_NC ("Finishing ReelWriters");
+
+ for (auto& i: _reels) {
+ write_hanging_text (i);
+ i.finish (output_dcp);
+ }
+
+ LOG_GENERAL_NC ("Writing XML");
+
+ dcp::DCP dcp (output_dcp);
+
+ auto cpl = make_shared<dcp::CPL>(
+ film()->dcp_name(),
+ film()->dcp_content_type()->libdcp_kind(),
+ film()->interop() ? dcp::Standard::INTEROP : dcp::Standard::SMPTE
+ );
+
+ dcp.add (cpl);
+
+ calculate_digests ();
/* Add reels */
diff --git a/src/lib/writer.h b/src/lib/writer.h
index aab7d5fc7..0ff011fa1 100644
--- a/src/lib/writer.h
+++ b/src/lib/writer.h
@@ -130,6 +130,7 @@ private:
void write_cover_sheet (boost::filesystem::path output_dcp);
void calculate_referenced_digests (boost::function<void (float)> set_progress);
void write_hanging_text (ReelWriter& reel);
+ void calculate_digests ();
std::weak_ptr<Job> _job;
std::vector<ReelWriter> _reels;