Speed up hints tests by not running a pointless audio analysis.
[dcpomatic.git] / src / lib / hints.cc
index fe2e5889cf1ae7625232e42769bd8b1882e3a4b3..40b51e81791544e70a6bdba7d7466dcfc605d4da 100644 (file)
 using std::cout;
 using std::make_shared;
 using std::max;
-using std::min;
-using std::pair;
 using std::shared_ptr;
 using std::string;
-using std::vector;
 using std::weak_ptr;
 using boost::optional;
 using boost::bind;
@@ -400,6 +397,7 @@ try
        check_ffec_and_ffmc_in_smpte_feature ();
        check_out_of_range_markers ();
        check_text_languages ();
+       check_audio_language ();
 
        if (check_loudness_done) {
                emit (bind(boost::ref(Progress), _("Examining subtitles and closed captions")));
@@ -407,9 +405,9 @@ try
                emit (bind(boost::ref(Progress), _("Examining audio, subtitles and closed captions")));
        }
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, Image::Alignment::COMPACT);
        player->set_ignore_video ();
-       if (check_loudness_done) {
+       if (check_loudness_done || _disable_audio_analysis) {
                /* We don't need to analyse audio because we already loaded a suitable analysis */
                player->set_ignore_audio ();
        }
@@ -637,3 +635,20 @@ Hints::check_text_languages ()
                }
        }
 }
+
+
+void
+Hints::check_audio_language ()
+{
+       auto content = film()->content();
+       auto mapped_audio =
+               std::find_if(content.begin(), content.end(), [](shared_ptr<const Content> c) {
+                       return c->audio && !c->audio->mapping().mapped_output_channels().empty();
+               });
+
+       if (mapped_audio != content.end() && !film()->audio_language()) {
+               hint (_("Some of your content has audio but you have not set the audio language.  It is advisable to set the audio language "
+                       "in the \"DCP\" tab unless your audio has no spoken parts."));
+       }
+}
+