Don't scan content if we don't need to (#2661).
authorCarl Hetherington <cth@carlh.net>
Fri, 8 Dec 2023 15:45:55 +0000 (16:45 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 9 Dec 2023 15:40:56 +0000 (16:40 +0100)
src/lib/hints.cc

index 55342a8d05dfcad7ce0919af97d19b762cb0b06c..7537317d40b77d89b80876699cadb48230621622 100644 (file)
@@ -374,8 +374,27 @@ Hints::scan_content(shared_ptr<const Film> film)
 {
        auto const check_loudness_done = check_loudness();
 
-       if (check_loudness_done) {
+       auto content = film->playlist()->content();
+       auto iter = std::find_if(content.begin(), content.end(), [](shared_ptr<const Content> content) {
+               auto text_iter = std::find_if(content->text.begin(), content->text.end(), [](shared_ptr<const TextContent> text) {
+                       return text->use();
+               });
+               return text_iter != content->text.end();
+       });
+
+       auto const have_text = iter != content.end();
+
+       if (check_loudness_done && !have_text) {
+               /* We don't need to check loudness, and we don't have any active text to check,
+                * so a scan of the content is pointless.
+                */
+               return;
+       }
+
+       if (check_loudness_done && have_text) {
                emit (bind(boost::ref(Progress), _("Examining subtitles and closed captions")));
+       } else if (!check_loudness_done && !have_text) {
+               emit (bind(boost::ref(Progress), _("Examining audio")));
        } else {
                emit (bind(boost::ref(Progress), _("Examining audio, subtitles and closed captions")));
        }