Move video level conversion for RGB from FFmpegImageProxy to Image.
[dcpomatic.git] / src / lib / hints.cc
index e767c07fef2fd68464ce1ffde8cad2efc0c05d96..4d3b2d95ee91161fddbde42a84fe3ab17c5e5322 100644 (file)
@@ -18,6 +18,7 @@
 
 */
 
+
 #include "dcp_content_type.h"
 #include "hints.h"
 #include "types.h"
@@ -45,6 +46,7 @@
 
 #include "i18n.h"
 
+
 using std::cout;
 using std::make_shared;
 using std::max;
@@ -82,12 +84,14 @@ Hints::Hints (weak_ptr<const Film> weak_film)
 
 }
 
+
 void
 Hints::start ()
 {
        _thread = boost::thread (bind(&Hints::thread, this));
 }
 
+
 Hints::~Hints ()
 {
        boost::this_thread::disable_interruption dis;
@@ -256,7 +260,7 @@ Hints::check_big_font_files ()
                for (auto i: film()->content()) {
                        for (auto j: i->text) {
                                for (auto k: j->fonts()) {
-                                       optional<boost::filesystem::path> const p = k->file ();
+                                       auto const p = k->file ();
                                        if (p && boost::filesystem::file_size(p.get()) >= (MAX_FONT_FILE_SIZE - SIZE_SLACK)) {
                                                big_font_files = true;
                                        }
@@ -276,7 +280,7 @@ Hints::check_vob ()
 {
        int vob = 0;
        for (auto i: film()->content()) {
-               if (boost::algorithm::starts_with (i->path(0).filename().string(), "VTS_")) {
+               if (boost::algorithm::starts_with(i->path(0).filename().string(), "VTS_")) {
                        ++vob;
                }
        }
@@ -330,8 +334,8 @@ Hints::check_loudness ()
 
                ch = ch.substr (0, ch.length() - 2);
 
-               if (!ch.empty ()) {
-                       hint (String::compose (
+               if (!ch.empty()) {
+                       hint(String::compose(
                                        _("Your audio level is very high (on %1).  You should reduce the gain of your audio content."),
                                        ch
                                        )
@@ -368,7 +372,10 @@ Hints::check_out_of_range_markers ()
 
 void
 Hints::thread ()
+try
 {
+       start_of_thread ("Hints");
+
        auto film = _film.lock ();
        if (!film) {
                return;
@@ -411,21 +418,17 @@ Hints::thread ()
        struct timeval last_pulse;
        gettimeofday (&last_pulse, 0);
 
-       try {
-               while (!player->pass()) {
+       while (!player->pass()) {
 
-                       struct timeval now;
-                       gettimeofday (&now, 0);
-                       if ((seconds(now) - seconds(last_pulse)) > 1) {
-                               if (_stop) {
-                                       break;
-                               }
-                               emit (bind (boost::ref(Pulse)));
-                               last_pulse = now;
+               struct timeval now;
+               gettimeofday (&now, 0);
+               if ((seconds(now) - seconds(last_pulse)) > 1) {
+                       if (_stop) {
+                               return;
                        }
+                       emit (bind (boost::ref(Pulse)));
+                       last_pulse = now;
                }
-       } catch (...) {
-               store_current ();
        }
 
        if (!check_loudness_done) {
@@ -446,16 +449,10 @@ Hints::thread ()
        bool ccap_mxf_too_big = false;
        bool subs_mxf_too_big = false;
 
-       boost::filesystem::path dcp_dir = film->dir("hints") / dcpomatic::get_process_id();
+       auto dcp_dir = film->dir("hints") / dcpomatic::get_process_id();
        boost::filesystem::remove_all (dcp_dir);
 
-       try {
-               _writer->finish (film->dir("hints") / dcpomatic::get_process_id());
-       } catch (...) {
-               store_current ();
-               emit (bind(boost::ref(Finished)));
-               return;
-       }
+       _writer->finish (film->dir("hints") / dcpomatic::get_process_id());
 
        dcp::DCP dcp (dcp_dir);
        dcp.read ();
@@ -489,6 +486,15 @@ Hints::thread ()
 
        emit (bind(boost::ref(Finished)));
 }
+catch (boost::thread_interrupted)
+{
+       /* The Hints object is being destroyed before it has finished, so just give up */
+}
+catch (...)
+{
+       store_current ();
+}
+
 
 void
 Hints::hint (string h)