Fix hints object so that its lifetime is (nearly) the same as its thread.
authorCarl Hetherington <cth@carlh.net>
Sat, 26 Jan 2019 22:42:18 +0000 (22:42 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 26 Jan 2019 22:42:18 +0000 (22:42 +0000)
Then when the thread AND Hints object are destroyed we get the Signaller's
destructor stuff to stop left-over hint signals being delivered.

Also add a hint about > 30fps DCP rates.

src/lib/hints.cc
src/lib/hints.h
src/wx/hints_dialog.cc
src/wx/hints_dialog.h

index 6238aa991b7e6a2550f4518109694c3e932edc70..a517470d50933259e9ad8d8d44f1f2e2a838c067 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -62,39 +62,29 @@ Hints::Hints (weak_ptr<const Film> film)
 }
 
 void
-Hints::stop_thread ()
+Hints::start ()
 {
-       if (_thread) {
-               try {
-                       {
-                               boost::mutex::scoped_lock lm (_mutex);
-                               _stop = true;
-                       }
-                       _thread->interrupt ();
-                       _thread->join ();
-               } catch (...) {
-
-               }
-
-               delete _thread;
-               _thread = 0;
-       }
+       _thread = new boost::thread (bind(&Hints::thread, this));
 }
 
 Hints::~Hints ()
 {
-       stop_thread ();
-}
+       if (!_thread) {
+               return;
+       }
 
-void
-Hints::start ()
-{
-       stop_thread ();
-       _long_ccap = false;
-       _overlap_ccap = false;
-       _too_many_ccap_lines = false;
-       _stop = false;
-       _thread = new boost::thread (bind(&Hints::thread, this));
+       try {
+               {
+                       boost::mutex::scoped_lock lm (_mutex);
+                       _stop = true;
+               }
+               _thread->interrupt ();
+               _thread->join ();
+       } catch (...) {
+
+       }
+
+       delete _thread;
 }
 
 void
@@ -187,6 +177,10 @@ Hints::thread ()
                hint (h);
        }
 
+       if (film->video_frame_rate() > 30) {
+               hint (String::compose(_("You are set up for a DCP at a frame rate of %1.  This frame rate is not supported by all projectors.  You are advised to change the DCP frame rate to %2."), film->video_frame_rate(), film->video_frame_rate() / 2));
+       }
+
        optional<double> lowest_speed_up;
        optional<double> highest_speed_up;
        BOOST_FOREACH (shared_ptr<const Content> i, content) {
index 35e3618421df8be4b9489c1ca1e5a1b192ed9477..6f0e533d407ae4d3dd549898688c74be2d4a11e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -45,7 +45,6 @@ public:
 
 private:
        void thread ();
-       void stop_thread ();
        void hint (std::string h);
        void text (PlayerText text, TextType type, DCPTimePeriod period);
 
index 18e8a6f9eb1cea6e3e7ddc87d5ad52532ada9c99..f8d03626fe06459195362566d810e71b4fe24294 100644 (file)
@@ -40,7 +40,7 @@ using boost::dynamic_pointer_cast;
 HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr<Film> film, bool ok)
        : wxDialog (parent, wxID_ANY, _("Hints"))
        , _film (film)
-       , _hints (new Hints (film))
+       , _hints (0)
        , _finished (false)
 {
        wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
@@ -82,11 +82,6 @@ HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr<Film> film, bool ok)
                _film_content_change_connection = locked_film->ContentChange.connect (boost::bind (&HintsDialog::film_content_change, this, _1));
        }
 
-       _hints->Hint.connect (bind (&HintsDialog::hint, this, _1));
-       _hints->Progress.connect (bind (&HintsDialog::progress, this, _1));
-       _hints->Pulse.connect (bind (&HintsDialog::pulse, this));
-       _hints->Finished.connect (bind (&HintsDialog::finished, this));
-
        film_change (CHANGE_TYPE_DONE);
 }
 
@@ -111,6 +106,12 @@ HintsDialog::film_change (ChangeType type)
        _gauge->SetValue (0);
        update ();
        _finished = false;
+
+       _hints.reset (new Hints (_film));
+       _hints->Hint.connect (bind (&HintsDialog::hint, this, _1));
+       _hints->Progress.connect (bind (&HintsDialog::progress, this, _1));
+       _hints->Pulse.connect (bind (&HintsDialog::pulse, this));
+       _hints->Finished.connect (bind (&HintsDialog::finished, this));
        _hints->start ();
 }
 
index 709587ac9dcd6ecb38d4ab0f45ef3da1599bb3a2..1fac9d11e63afa43ac33d65d52bc30e4089be00b 100644 (file)
@@ -46,7 +46,7 @@ private:
        wxGauge* _gauge;
        wxStaticText* _gauge_message;
        wxRichTextCtrl* _text;
-       boost::shared_ptr<Hints> _hints;
+       boost::scoped_ptr<Hints> _hints;
        std::list<std::string> _current;
        bool _finished;