diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-07-20 00:51:23 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-07-20 10:18:17 +0200 |
| commit | 4bdaccb5ede7d9a1066e0a0665fcfce9b1e3241e (patch) | |
| tree | e8473bb1a1b4736e88a973dc25bcfa369c3ad000 /src/tools/dcpomatic_disk_writer.cc | |
| parent | 6d101863c87b34af5c3992168182e80445e56ec7 (diff) | |
Allow multiple DCPs to be written to a disk (#1756).
Diffstat (limited to 'src/tools/dcpomatic_disk_writer.cc')
| -rw-r--r-- | src/tools/dcpomatic_disk_writer.cc | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc index dca09f729..ef3bf2f77 100644 --- a/src/tools/dcpomatic_disk_writer.cc +++ b/src/tools/dcpomatic_disk_writer.cc @@ -195,16 +195,27 @@ try } }); } else if (*s == DISK_WRITER_WRITE) { - auto dcp_path_opt = nanomsg->receive (LONG_TIMEOUT); auto device_opt = nanomsg->receive (LONG_TIMEOUT); - if (!dcp_path_opt || !device_opt) { + if (!device_opt) { LOG_DISK_NC("Failed to receive write request"); throw CommunicationFailedError(); } - - auto dcp_path = *dcp_path_opt; auto device = *device_opt; + vector<boost::filesystem::path> dcp_paths; + while (true) { + auto dcp_path_opt = nanomsg->receive (LONG_TIMEOUT); + if (!dcp_path_opt) { + LOG_DISK_NC("Failed to receive write request"); + throw CommunicationFailedError(); + } + if (*dcp_path_opt != "") { + dcp_paths.push_back(*dcp_path_opt); + } else { + break; + } + } + /* Do some basic sanity checks; this is a bit belt-and-braces but it can't hurt... */ #ifdef DCPOMATIC_OSX @@ -249,11 +260,14 @@ try return true; } - LOG_DISK ("Here we go writing %1 to %2", dcp_path, device); + LOG_DISK("Here we go writing these to %1", device); + for (auto dcp: dcp_paths) { + LOG_DISK(" %1", dcp); + } request_privileges ( "com.dcpomatic.write-drive", - [dcp_path, device]() { + [dcp_paths, device]() { #if defined(DCPOMATIC_LINUX) auto posix_partition = device; /* XXX: don't know if this logic is sensible */ @@ -262,12 +276,12 @@ try } else { posix_partition += "1"; } - dcpomatic::write (dcp_path, device, posix_partition, nanomsg); + dcpomatic::write (dcp_paths, device, posix_partition, nanomsg); #elif defined(DCPOMATIC_OSX) auto fast_device = boost::algorithm::replace_first_copy (device, "/dev/disk", "/dev/rdisk"); - dcpomatic::write (dcp_path, fast_device, fast_device + "s1", nanomsg); + dcpomatic::write (dcp_paths, fast_device, fast_device + "s1", nanomsg); #elif defined(DCPOMATIC_WINDOWS) - dcpomatic::write (dcp_path, device, "", nanomsg); + dcpomatic::write (dcp_paths, device, "", nanomsg); #endif }, []() { |
