Check that we have a connection to the disk writer before starting to use it in earnest.
authorCarl Hetherington <cth@carlh.net>
Thu, 6 Aug 2020 22:10:59 +0000 (00:10 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 6 Aug 2020 22:10:59 +0000 (00:10 +0200)
src/lib/disk_writer_messages.h
src/tools/dcpomatic_disk.cc
src/tools/dcpomatic_disk_writer.cc

index d31a9cb0ad50c8b63455280b4150d77360bbbed1..406afc61da866b36001582e5b374514ce19478f5 100644 (file)
  * by \n.
  */
 
+/* PING */
+
+// Front-end sends:
+
+#define DISK_WRITER_PING "P"
+
+// Back-end responds
+
+#define DISK_WRITER_PONG "O"
+
 /* REQUEST TO WRITE DCP */
 
 // Front-end sends:
index b94d4bf941016c4deb5e898040c7e50995c88fe5..7bea4d8e911693f81a4288657e87328133b1a484 100644 (file)
@@ -210,6 +210,31 @@ private:
                DCPOMATIC_ASSERT (_drive->GetSelection() != wxNOT_FOUND);
                DCPOMATIC_ASSERT (static_cast<bool>(_dcp_path));
 
+               bool have_writer = true;
+               if (!_nanomsg.send(DISK_WRITER_PING "\n", 2000)) {
+                       have_writer = false;
+               } else {
+                       optional<string> reply = _nanomsg.receive (2000);
+                       if (!reply || *reply != DISK_WRITER_PONG) {
+                               have_writer = false;
+                       }
+               }
+
+               if (!have_writer) {
+#ifdef DCPOMATIC_WINDOWS
+                       MessageDialog* m = new MessageDialog (
+                               this,
+                               _("DCP-o-matic Disk Writer"),
+                               _("Do you see a 'User Account Control' dialogue asking about dcpomatic2_disk_writer.exe?  If so, click 'Yes', then try again.")
+                               );
+                       m->ShowModal ();
+                       m->Destroy ();
+                       return;
+#else
+                       throw CommunicationFailedError ();
+#endif
+               }
+
                Drive const& drive = _drives[_drive->GetSelection()];
                if (drive.mounted()) {
                        TryUnmountDialog* d = new TryUnmountDialog(this, drive.description());
index 2c3753e57e9c318bae90ee9670859294cee1483c..a2788e18bf0259cb3526335cc88d42cb8345a460 100644 (file)
@@ -460,6 +460,8 @@ try
 
        if (*s == DISK_WRITER_QUIT) {
                exit (EXIT_SUCCESS);
+       } else if (*s == DISK_WRITER_PING) {
+               nanomsg->send(DISK_WRITER_PONG "\n", LONG_TIMEOUT);
        } else if (*s == DISK_WRITER_UNMOUNT) {
                /* XXX: should do Linux polkit stuff here */
                optional<string> xml_head = nanomsg->receive (LONG_TIMEOUT);