Improve disk_writer_messages.h commenting and add DISK_WRITER_QUIT and DISK_WRITER_WR...
authorCarl Hetherington <cth@carlh.net>
Wed, 8 Apr 2020 22:49:35 +0000 (00:49 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 8 Apr 2020 22:49:35 +0000 (00:49 +0200)
src/lib/copy_to_drive_job.cc
src/lib/disk_writer_messages.h
src/tools/dcpomatic_disk_writer.cc

index b7bb5a60d26844334c4bcb383179dec484487056..fe35daba6c4b0b1b6061617945fd44ed1719e568 100644 (file)
@@ -63,7 +63,7 @@ CopyToDriveJob::json_name () const
 void
 CopyToDriveJob::run ()
 {
-       if (!_nanomsg.nonblocking_send(String::compose("W\n%1\n%2\n", _dcp.string(), _drive.internal_name()))) {
+       if (!_nanomsg.nonblocking_send(String::compose(DISK_WRITER_WRITE "\n%1\n%2\n", _dcp.string(), _drive.internal_name()))) {
                throw CopyError ("Could not communicate with writer process", 0);
        }
 
index 61cdbcfbddebaa3c119ebf5d092163a5b7b45334..39253a76e3e0d2989c4bcc9e7f55c0793cf97bd1 100644 (file)
 
 */
 
-/* dcpomatic_disk_writer receives
-
-DCP pathname\n
-Internal name of drive to write to\n
+/* We have the front-end application dcpomatic2_disk and the back-end
+ * dcpomatic2_disk_writer.  The communication is line-based, separated
+ * by \n.
+ */
 
-   Then responds with one of the following.
-*/
+/* REQUEST TO WRITE DCP */
 
-/** Write finished and everything was OK, e.g.
+// Front-end sends:
+#define DISK_WRITER_WRITE "W"
+// DCP pathname
+// Internal name of the drive to write to
 
-D\n
+// Back-end responds:
 
-*/
+// everything is ok
 #define DISK_WRITER_OK "D"
 
-/** There was an error.  Following this will come
-
-error message\n
-error number\n
-
-e.g.
-
-E\n
-Disc full\n
-42\n
-
-*/
+// there was an error
 #define DISK_WRITER_ERROR "E"
+// Error message
+// Error number
 
-/** The disk writer is formatting the drive.  It is not possible
- *  to give progress reports on this so the writer just tells us
- *  it's happening.  This is finished when DISK_WRITER_PROGRESS
- *  messages start arriving
- */
+//  the drive is being formatted
 #define DISK_WRITER_FORMATTING "F"
 
-/** Some progress has been made in the main "copy" part of the task.
- *  Following this will come
+// data is being copied, 30% done
+#define DISK_WRITER_PROGRESS "P"
+// 0.3\n
 
-progress as a float from 0 to 1\n
 
-e.g.
+/* REQUEST TO QUIT */
 
-P\n
-0.3\n
+// Front-end sends:
+#define DISK_WRITER_QUIT "Q"
 
-*/
-#define DISK_WRITER_PROGRESS "P"
 
-/** dcpomatic_disk_writer may also receive
+/* REQUEST TO UNMOUNT A DRIVE */
 
-Q\n
+// Front-end sends:
+#define DISK_WRITER_UNMOUNT "U"
+// Internal name of the drive to write to
 
-as a request to quit.
-*/
-#define DISK_WRITER_QUIT "Q"
+// Back-end responds:
+// DISK_WRITER_OK
+// or
+// DISK_WRITER_ERROR
 
index 0bd5dcbc451c80c5875450f3e44105bf4cbae03c..9518ac555a1f2afdabf2d4cef776f2c831c2f008 100644 (file)
@@ -386,9 +386,9 @@ idle ()
                return true;
        }
 
-       if (*s == "Q") {
+       if (*s == DISK_WRITER_QUIT) {
                exit (EXIT_SUCCESS);
-       } else if (*s == "W") {
+       } else if (*s == DISK_WRITER_WRITE) {
                dcp_path = nanomsg->blocking_get();
                device = nanomsg->blocking_get();