Fix incorrect results when applying some timing operations to
[dcpomatic.git] / src / wx / swaroop_controls.cc
index aa3a095ec459411bd487f3bdac4f14b81658e259..33db37babb57f1bedecaab84a2e50e5b055a9344 100644 (file)
@@ -125,8 +125,10 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
 void
 SwaroopControls::check_restart ()
 {
+       cout << "check_restart called\n";
        FILE* f = fopen_boost (Config::path("position"), "r");
        if (!f) {
+               cout << "could not open position file (" << errno << ")\n";
                return;
        }
 
@@ -135,8 +137,11 @@ SwaroopControls::check_restart ()
        int64_t time;
        fscanf (f, "%63s %d %ld", id, &index, &time);
 
+       cout << "Looking for playlist " << id << " to restart.\n";
+
        for (size_t i = 0; i < _playlists.size(); ++i) {
                if (_playlists[i].id() == id) {
+                       cout << "Found playlist " << id << "\n";
                        select_playlist (i, index);
                        update_current_content ();
                        _viewer->seek (DCPTime(time), false);
@@ -161,6 +166,10 @@ SwaroopControls::viewer_position_changed ()
                        + " " + dcp::raw_convert<string>(_viewer->position().get());
 
                checked_fwrite (p.c_str(), p.length(), f, Config::path("position"));
+#ifdef DCPOMATIC_LINUX
+               fflush (f);
+               fsync (fileno(f));
+#endif
                fclose (f);
        }
 }
@@ -266,7 +275,7 @@ SwaroopControls::log (wxString s)
        wxString ts = std_to_wx(string(buffer)) + N_(": ");
        _log->SetValue(_log->GetValue() + ts + s + "\n");
 
-       optional<boost::filesystem::path> log = Config::instance()->player_log_file();
+       optional<boost::filesystem::path> log = Config::instance()->player_activity_log_file();
        if (!log) {
                return;
        }
@@ -339,7 +348,7 @@ SwaroopControls::get_kdm_from_url (shared_ptr<DCPContent> dcp)
        string url = Config::instance()->kdm_server_url();
        boost::algorithm::replace_all (url, "{CPL}", *dcp->cpl());
        optional<dcp::EncryptedKDM> kdm;
-       if (dcp->cpl() && !get_from_url(url, false, temp)) {
+       if (dcp->cpl() && !get_from_url(url, false, false, temp)) {
                try {
                        kdm = dcp::EncryptedKDM (dcp::file_to_string(temp.file()));
                        if (kdm->cpl_id() != dcp->cpl()) {