Add some logging to show what's going on with the wxDisplays.
[dcpomatic.git] / src / tools / dcpomatic_disk.cc
index a6ae58c8d704f00c70a4d9f8a7d0f121ea829fba..5941d6d7038d8d508cc15d92cdb3e454cd77a921 100644 (file)
@@ -39,6 +39,7 @@
 #include "lib/signal_manager.h"
 #include "lib/util.h"
 #include "lib/version.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 #include <wx/cmdline.h>
 #include <wx/wx.h>
@@ -85,7 +86,7 @@ public:
        boost::optional<boost::filesystem::path> get () const
        {
                auto const dcp = boost::filesystem::path(wx_to_std(GetPath()));
-               if (!boost::filesystem::exists(dcp / "ASSETMAP") && !boost::filesystem::exists(dcp / "ASSETMAP.xml")) {
+               if (!dcp::filesystem::exists(dcp / "ASSETMAP") && !dcp::filesystem::exists(dcp / "ASSETMAP.xml")) {
                        error_dialog (nullptr, _("No ASSETMAP or ASSETMAP.xml found in this folder.  Please choose a DCP folder."));
                        return {};
                }
@@ -284,11 +285,11 @@ private:
 
                auto ping = [this](int attempt) {
                        if (_nanomsg.send(DISK_WRITER_PING "\n", 1000)) {
-                               auto reply = _nanomsg.receive (1000);
-                               if (reply && *reply == DISK_WRITER_PONG) {
+                               auto reply = DiskWriterBackEndResponse::read_from_nanomsg(_nanomsg, 1000);
+                               if (reply && reply->type() == DiskWriterBackEndResponse::Type::PONG) {
                                        return true;
                                } else if (reply) {
-                                       LOG_DISK("Unexpected response %1 to ping received (attempt %2)", *reply, attempt);
+                                       LOG_DISK("Unexpected response %1 to ping received (attempt %2)", static_cast<int>(reply->type()), attempt);
                                } else {
                                        LOG_DISK("No reply received from ping (attempt %1)", attempt);
                                }
@@ -348,12 +349,16 @@ private:
                                throw CommunicationFailedError ();
                        }
                        /* The reply may have to wait for the user to authenticate, so let's wait a while */
-                       auto reply = _nanomsg.receive (30000);
-                       if (!reply || *reply != DISK_WRITER_OK) {
+                       auto const reply = DiskWriterBackEndResponse::read_from_nanomsg(_nanomsg, 30000);
+                       if (!reply || reply->type() != DiskWriterBackEndResponse::Type::OK) {
                                auto m = make_wx<MessageDialog>(
                                                this,
                                                _("DCP-o-matic Disk Writer"),
-                                               wxString::Format(_("The drive %s could not be unmounted.\nClose any application that is using it, then try again."), std_to_wx(drive.description()))
+                                               wxString::Format(
+                                                       _("The drive %s could not be unmounted.\nClose any application that is using it, then try again. (%s)"),
+                                                       std_to_wx(drive.description()),
+                                                       reply->error_message()
+                                                       )
                                                );
                                m->ShowModal ();
                                return;