Add and use Content::has_mapped_audio().
authorCarl Hetherington <cth@carlh.net>
Sun, 19 May 2024 21:27:34 +0000 (23:27 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 19 May 2024 21:27:34 +0000 (23:27 +0200)
src/lib/content.cc
src/lib/content.h
src/lib/dcp_content.cc
src/lib/dcp_decoder.cc
src/lib/ffmpeg_decoder.cc
src/lib/hints.cc
src/lib/player.cc
src/wx/timeline.cc

index 6324050ec69a22f056cc3bedb4c1c7ae2ff002f0..f13201b93b1351d3fe7328056b404767bc52bf7a 100644 (file)
@@ -570,3 +570,11 @@ Content::changed () const
 
        return (write_time_changed || calculate_digest() != digest());
 }
+
+
+bool
+Content::has_mapped_audio() const
+{
+       return audio && !audio->mapping().mapped_output_channels().empty();
+}
+
index f2fecddf063df96a2546fffb66cd82722922aa13..540abdd8acf4f863d48ff81e15dd969fdc3e349b 100644 (file)
@@ -203,6 +203,8 @@ public:
                return true;
        }
 
+       bool has_mapped_audio() const;
+
        /* ChangeType::PENDING and ChangeType::CANCELLED may be emitted from any thread; ChangeType::DONE always from GUI thread */
        boost::signals2::signal<void (ChangeType, std::weak_ptr<Content>, int, bool)> Change;
 
index bdd5e0e091c0aa6b523ec7c7400ec9449beef3a0..6e573c6390404ff5a31f20f8237afccc5a32a07b 100644 (file)
@@ -731,7 +731,7 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c
        /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
        return can_reference(
                film, [](shared_ptr<const Content> c) {
-                       return static_cast<bool>(c->audio) && !c->audio->mapping().mapped_output_channels().empty();
+                       return c->has_mapped_audio();
                },
                _("it overlaps other audio content; remove the other content."),
                why_not
index 17f0e73b5d1ccf58e9349cb608c6fe7571b954a2..727dcbf26d10ed540ac4231277316aaab4cfe923 100644 (file)
@@ -77,7 +77,7 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
                if (content->video) {
                        video = make_shared<VideoDecoder>(this, content);
                }
-               if (content->audio && !content->audio->mapping().mapped_output_channels().empty()) {
+               if (content->has_mapped_audio()) {
                        audio = make_shared<AudioDecoder>(this, content->audio, fast);
                }
                for (auto i: content->text) {
index e0d9918b207856e4e70b44a39d4e34f318be3990..019e4f95c6080061579178da6b9cdd2ab87d5188 100644 (file)
@@ -89,7 +89,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmp
                _pts_offset = {};
        }
 
-       if (c->audio && !c->audio->mapping().mapped_output_channels().empty()) {
+       if (c->has_mapped_audio()) {
                audio = make_shared<AudioDecoder>(this, c->audio, fast);
        }
 
index bbd5ae5d594e5a3b1b81ac4f3ad1ab7bb4ba10ae..2e2a8fd7b0c4489bd269f25427a1abb81a8eb0cf 100644 (file)
@@ -698,7 +698,7 @@ 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();
+                       return c->has_mapped_audio();
                });
 
        if (mapped_audio != content.end() && !film()->audio_language()) {
index 27c89a2fa2f63a1235c7982076bfb8c8a62b94db..47067af5aa70bb6b60307fd75a47b80269d1cdd2 100644 (file)
@@ -251,7 +251,7 @@ have_video (shared_ptr<const Content> content)
 bool
 have_audio (shared_ptr<const Content> content)
 {
-       return static_cast<bool>(content->audio) && !content->audio->mapping().mapped_output_channels().empty() && content->can_be_played();
+       return content->has_mapped_audio() && content->can_be_played();
 }
 
 
index 38e9de4ee46318ca73bfff98a29023c64bac5047..2789d2a5486a903ef94656ad9f3cd6fda6652b62 100644 (file)
@@ -315,7 +315,7 @@ Timeline::recreate_views ()
                        _views.push_back (make_shared<TimelineVideoContentView>(*this, i));
                }
 
-               if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) {
+               if (i->has_mapped_audio()) {
                        _views.push_back (make_shared<TimelineAudioContentView>(*this, i));
                }