Add hint when no audio language is set (#2033).
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Jun 2021 15:10:16 +0000 (17:10 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Jun 2021 15:10:16 +0000 (17:10 +0200)
src/lib/hints.cc
src/lib/hints.h
test/hints_test.cc

index fe2e5889cf1ae7625232e42769bd8b1882e3a4b3..64122db8d5bab6be1ab41a6d14d5c68933a66d2a 100644 (file)
@@ -400,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")));
@@ -637,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."));
+       }
+}
+
index 81a37a3c453adb10aabfc462604b393ac3a4d2e7..2a5e8d4a024f4ba28148c7a42a80b2bcd61d3c2e 100644 (file)
@@ -78,6 +78,7 @@ private:
        void check_ffec_and_ffmc_in_smpte_feature ();
        void check_out_of_range_markers ();
        void check_text_languages ();
+       void check_audio_language ();
 
        boost::thread _thread;
        /** This is used to make a partial DCP containing only the subtitles and closed captions that
index 16d130f22a65c04232b3c4cda000c4cb9d83967c..263f02435a70a4a419718aea3209b93ec84ef6c7 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 
+#include "lib/audio_content.h"
 #include "lib/content.h"
 #include "lib/content_factory.h"
 #include "lib/cross.h"
@@ -237,3 +238,20 @@ BOOST_AUTO_TEST_CASE (hints_destroyed_while_running)
        dcpomatic_sleep_seconds (1);
 }
 
+
+BOOST_AUTO_TEST_CASE (hints_audio_with_no_language)
+{
+       auto content = content_factory("test/data/sine_440.wav").front();
+       auto film = new_test_film2 ("hints_audio_with_no_language", { content });
+       content->audio->set_gain (-6);
+
+       auto hints = get_hints (film);
+       BOOST_REQUIRE_EQUAL (hints.size(), 1U);
+       BOOST_CHECK_EQUAL (
+               hints[0],
+               "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."
+               );
+
+}
+