Fix player stress testing with expanded controls.
authorCarl Hetherington <cth@carlh.net>
Sun, 15 Mar 2020 22:22:50 +0000 (23:22 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 15 Mar 2020 22:22:50 +0000 (23:22 +0100)
Also correctly wait with a stress test until the DCP open
has completely finished.

src/tools/dcpomatic_player.cc
src/wx/playlist_controls.cc
src/wx/playlist_controls.h

index cb81c5b89d7aaa24a2fc4bdfc4aee7cd97f5ac49..bbbbe3a1d20574fa2eab24591c2a9c1e9c745cba 100644 (file)
@@ -199,6 +199,7 @@ public:
                , _view_dual_screen (0)
 #ifdef DCPOMATIC_PLAYER_STRESS_TEST
                , _timer (this)
                , _view_dual_screen (0)
 #ifdef DCPOMATIC_PLAYER_STRESS_TEST
                , _timer (this)
+               , _stress_suspended (false)
 #endif
 {
                dcpomatic_log.reset (new NullLog());
 #endif
 {
                dcpomatic_log.reset (new NullLog());
@@ -319,6 +320,10 @@ public:
 
        void check_commands ()
        {
 
        void check_commands ()
        {
+               if (_stress_suspended) {
+                       return;
+               }
+
                if (_current_command == _commands.end()) {
                        _timer.Stop ();
                        cout << "ST: finished.\n";
                if (_current_command == _commands.end()) {
                        _timer.Stop ();
                        cout << "ST: finished.\n";
@@ -327,7 +332,6 @@ public:
 
                switch (_current_command->type) {
                        case Command::OPEN:
 
                switch (_current_command->type) {
                        case Command::OPEN:
-                               cout << "ST: load " << _current_command->string_param << "\n";
                                load_dcp (_current_command->string_param);
                                ++_current_command;
                                break;
                                load_dcp (_current_command->string_param);
                                ++_current_command;
                                break;
@@ -504,8 +508,11 @@ public:
 
                reset_film ();
                try {
 
                reset_film ();
                try {
+                       _stress_suspended = true;
                        shared_ptr<DCPContent> dcp (new DCPContent(dir));
                        shared_ptr<DCPContent> dcp (new DCPContent(dir));
-                       _film->examine_and_add_content (dcp, true);
+                       shared_ptr<Job> job (new ExamineContentJob(_film, dcp));
+                       _examine_job_connection = job->Finished.connect(bind(&DOMFrame::add_dcp_to_film, this, weak_ptr<Job>(job), weak_ptr<Content>(dcp)));
+                       JobManager::instance()->add (job);
                        bool const ok = display_progress (_("DCP-o-matic Player"), _("Loading content"));
                        if (!ok || !report_errors_from_last_job(this)) {
                                return;
                        bool const ok = display_progress (_("DCP-o-matic Player"), _("Loading content"));
                        if (!ok || !report_errors_from_last_job(this)) {
                                return;
@@ -518,6 +525,22 @@ public:
                }
        }
 
                }
        }
 
+       void add_dcp_to_film (weak_ptr<Job> weak_job, weak_ptr<Content> weak_content)
+       {
+               shared_ptr<Job> job = weak_job.lock ();
+               if (!job || !job->finished_ok()) {
+                       return;
+               }
+
+               shared_ptr<Content> content = weak_content.lock ();
+               if (!content) {
+                       return;
+               }
+
+               _film->add_content (content);
+               _stress_suspended = false;
+       }
+
        void reset_film_weak (weak_ptr<Film> weak_film)
        {
                shared_ptr<Film> film = weak_film.lock ();
        void reset_film_weak (weak_ptr<Film> weak_film)
        {
                shared_ptr<Film> film = weak_film.lock ();
@@ -1131,6 +1154,7 @@ private:
        SystemInformationDialog* _system_information_dialog;
        boost::shared_ptr<Film> _film;
        boost::signals2::scoped_connection _config_changed_connection;
        SystemInformationDialog* _system_information_dialog;
        boost::shared_ptr<Film> _film;
        boost::signals2::scoped_connection _config_changed_connection;
+       boost::signals2::scoped_connection _examine_job_connection;
        wxMenuItem* _file_add_ov;
        wxMenuItem* _file_add_kdm;
        wxMenuItem* _tools_verify;
        wxMenuItem* _file_add_ov;
        wxMenuItem* _file_add_kdm;
        wxMenuItem* _tools_verify;
@@ -1142,6 +1166,7 @@ private:
        list<Command>::const_iterator _current_command;
        /** Remaining time that the script must wait, in milliseconds */
        optional<int> _wait_remaining;
        list<Command>::const_iterator _current_command;
        /** Remaining time that the script must wait, in milliseconds */
        optional<int> _wait_remaining;
+       bool _stress_suspended;
 #endif
 };
 
 #endif
 };
 
index 844e15f04e30db85331a7b4c1a7a52fd620ac928..edc4485e66cba8095a5e677941a634132d6508f9 100644 (file)
@@ -454,3 +454,17 @@ PlaylistControls::viewer_finished ()
                _pause_button->Enable (false);
        }
 }
                _pause_button->Enable (false);
        }
 }
+
+#ifdef DCPOMATIC_PLAYER_STRESS_TEST
+void
+PlaylistControls::play ()
+{
+       play_clicked ();
+}
+
+void
+PlaylistControls::stop ()
+{
+       stop_clicked ();
+}
+#endif
index dd6b77788e147c6a11444208c29b17dfaa69171f..4609242172badef0dfc7d7075059c0fe8ad25ba9 100644 (file)
@@ -37,6 +37,11 @@ public:
        */
        boost::signals2::signal<void (boost::weak_ptr<Film>)> ResetFilm;
 
        */
        boost::signals2::signal<void (boost::weak_ptr<Film>)> ResetFilm;
 
+#ifdef DCPOMATIC_PLAYER_STRESS_TEST
+       void play ();
+       void stop ();
+#endif
+
 private:
        void play_clicked ();
        void pause_clicked ();
 private:
        void play_clicked ();
        void pause_clicked ();