- DCPOMATIC_ASSERT (static_cast<bool>(_dcp_path));
- DriveWipeWarningDialog* d = new DriveWipeWarningDialog (this, _drive->GetString(_drive->GetSelection()));
- int const r = d->ShowModal ();
- bool ok = r == wxID_OK && d->confirmed();
- d->Destroy ();
+ DCPOMATIC_ASSERT (!_dcp_paths.empty());
+
+ auto ping = [this](int attempt) {
+ if (_nanomsg.send(DISK_WRITER_PING "\n", 1000)) {
+ 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)", static_cast<int>(reply->type()), attempt);
+ } else {
+ LOG_DISK("No reply received from ping (attempt %1)", attempt);
+ }
+ } else {
+ LOG_DISK("Could not send ping to writer (attempt %1)", attempt);
+ }
+ dcpomatic_sleep_seconds (1);
+ return false;
+ };
+
+ bool have_writer = false;
+ for (int i = 0; i < 8; ++i) {
+ if (ping(i + 1)) {
+ have_writer = true;
+ break;
+ }
+ }
+
+ if (!have_writer) {
+#if defined(DCPOMATIC_WINDOWS)
+ auto m = make_wx<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 ();
+ return;
+#elif defined(DCPOMATIC_OSX)
+ auto m = make_wx<MessageDialog>(
+ this,
+ _("DCP-o-matic Disk Writer"),
+ _("Did you install the DCP-o-matic Disk Writer.pkg from the .dmg? Please check and try again.")
+ );
+ m->ShowModal ();
+ return;
+#else
+ LOG_DISK_NC ("Failed to ping writer");
+ throw CommunicationFailedError ();
+#endif
+ }
+
+ auto const& drive = _drives[_drive->GetSelection()];
+ if (drive.mounted()) {
+ auto d = make_wx<TryUnmountDialog>(this, drive.description());
+ int const r = d->ShowModal ();
+ if (r != wxID_OK) {
+ return;
+ }