Fix incorrect results when applying some timing operations to
[dcpomatic.git] / src / wx / swaroop_controls.cc
index d16f36132efd969ec27fbd614d1122bef15e9f52..33db37babb57f1bedecaab84a2e50e5b055a9344 100644 (file)
@@ -118,13 +118,17 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
 
        _content_view->update ();
        update_playlist_directory ();
+
+       _viewer->set_background_image (true);
 }
 
 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;
        }
 
@@ -133,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);
@@ -159,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);
        }
 }
@@ -169,6 +180,7 @@ SwaroopControls::started ()
        Controls::started ();
        _play_button->Enable (false);
        _pause_button->Enable (true);
+       _viewer->set_background_image (false);
 }
 
 void
@@ -214,6 +226,7 @@ SwaroopControls::stop_clicked ()
                _selected_playlist_position = 0;
                update_current_content ();
        }
+       _viewer->set_background_image (true);
 }
 
 bool
@@ -262,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;
        }
@@ -335,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()) {
@@ -511,6 +524,7 @@ SwaroopControls::viewer_finished ()
                }
        } else {
                _selected_playlist_position = 0;
+               _viewer->set_background_image (true);
                ResetFilm (shared_ptr<Film>(new Film(optional<boost::filesystem::path>())));
        }
 }