Fix _writer process shutdown a little.
authorcah <cah@ableton.com>
Fri, 27 Mar 2020 23:35:16 +0000 (00:35 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 28 Mar 2020 18:47:28 +0000 (19:47 +0100)
src/lib/copy_to_drive_job.cc
src/tools/dcpomatic_dist.cc
src/tools/dcpomatic_dist_writer.cc

index 68055f7e9d8e2c9970074820f40f4afe22e7bbe9..34bffe0e8b42dcf71bab6abba057a417e4118721 100644 (file)
@@ -63,7 +63,7 @@ CopyToDriveJob::json_name () const
 void
 CopyToDriveJob::run ()
 {
-       _nanomsg.send(String::compose("%1\n%2\n", _dcp.string(), _drive.internal_name()));
+       _nanomsg.send(String::compose("W\n%1\n%2\n", _dcp.string(), _drive.internal_name()));
 
        while (true) {
                string s = _nanomsg.blocking_get ();
index c94062568a9211f52662fedb95320949f00b1ebb..2098eb1a5e554f9f277b1963ec78b4fb989e9a81 100644 (file)
@@ -126,8 +126,7 @@ public:
 
        ~DOMFrame ()
        {
-               _writer->terminate ();
-               delete _writer;
+               _nanomsg.send("Q\n");
        }
 
 private:
@@ -281,12 +280,6 @@ public:
                return true;
        }
 
-       int OnExit ()
-       {
-               _frame->Destroy ();
-               return 0;
-       }
-
        void config_failed_to_load ()
        {
                message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
index 04325dd5b617bb9e8f53558f94e627e78282d2cd..c667f2f95ee0f051862a7db94f7415938faf4169 100644 (file)
@@ -365,20 +365,25 @@ idle ()
                return true;
        }
 
-       dcp_path = *s;
-       device = nanomsg->blocking_get();
+       if (*s == "Q") {
+               exit (EXIT_SUCCESS);
+       } else if (*s == "W") {
+               dcp_path = nanomsg->blocking_get();
+               device = nanomsg->blocking_get();
 
-       LOG_DIST ("Here we go writing %1 to %2", dcp_path, device);
+               LOG_DIST ("Here we go writing %1 to %2", dcp_path, device);
 
 #ifdef DCPOMATIC_LINUX
-       polkit_authority = polkit_authority_get_sync (0, 0);
-       PolkitSubject* subject = polkit_unix_process_new (getppid());
-       polkit_authority_check_authorization (
-                       polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, 0
-                       );
+               polkit_authority = polkit_authority_get_sync (0, 0);
+               PolkitSubject* subject = polkit_unix_process_new (getppid());
+               polkit_authority_check_authorization (
+                               polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, 0
+                               );
 #else
-       write ();
+               write ();
 #endif
+       }
+
        return true;
 }