C++11 tidying.
[dcpomatic.git] / src / lib / hints.cc
index b23f32238182e1f603655ada06a2e24d51bc1807..64122db8d5bab6be1ab41a6d14d5c68933a66d2a 100644 (file)
 
 */
 
+
+#include "audio_analysis.h"
+#include "audio_content.h"
+#include "audio_processor.h"
+#include "compose.hpp"
+#include "content.h"
+#include "cross.h"
 #include "dcp_content_type.h"
-#include "hints.h"
-#include "types.h"
 #include "film.h"
-#include "content.h"
-#include "video_content.h"
-#include "text_content.h"
-#include "audio_processor.h"
 #include "font.h"
 #include "font_data.h"
+#include "hints.h"
+#include "player.h"
 #include "ratio.h"
-#include "audio_analysis.h"
-#include "compose.hpp"
+#include "text_content.h"
+#include "types.h"
 #include "util.h"
-#include "cross.h"
-#include "player.h"
+#include "video_content.h"
 #include "writer.h"
 #include <dcp/cpl.h>
 #include <dcp/raw_convert.h>
@@ -45,6 +47,7 @@
 
 #include "i18n.h"
 
+
 using std::cout;
 using std::make_shared;
 using std::max;
@@ -82,12 +85,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;
@@ -152,7 +157,7 @@ Hints::check_unusual_container ()
 {
        auto const film_container = film()->container()->id();
        if (film_container != "185" && film_container != "239") {
-               hint (_("Your DCP uses an unusual container ratio.  This may cause problems on some projectors.  If possible, use Flat or Scope for the DCP container ratio"));
+               hint (_("Your DCP uses an unusual container ratio.  This may cause problems on some projectors.  If possible, use Flat or Scope for the DCP container ratio."));
        }
 }
 
@@ -256,7 +261,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 +281,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 +335,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
                                        )
@@ -370,6 +375,8 @@ void
 Hints::thread ()
 try
 {
+       start_of_thread ("Hints");
+
        auto film = _film.lock ();
        if (!film) {
                return;
@@ -393,6 +400,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")));
@@ -443,7 +451,7 @@ try
        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);
 
        _writer->finish (film->dir("hints") / dcpomatic::get_process_id());
@@ -489,6 +497,7 @@ catch (...)
        store_current ();
 }
 
+
 void
 Hints::hint (string h)
 {
@@ -629,3 +638,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."));
+       }
+}
+