summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-05-19 23:27:34 +0200
committerCarl Hetherington <cth@carlh.net>2024-05-19 23:27:34 +0200
commitfd198a9cb1f033773102f54603bd06b98f3c7fb1 (patch)
tree29eb553140487ad3c841b2c4348c122438c918a9
parent60d53efe2cb3bddf98ca3cba937247a8024e7d63 (diff)
Add and use Content::has_mapped_audio().
-rw-r--r--src/lib/content.cc8
-rw-r--r--src/lib/content.h2
-rw-r--r--src/lib/dcp_content.cc2
-rw-r--r--src/lib/dcp_decoder.cc2
-rw-r--r--src/lib/ffmpeg_decoder.cc2
-rw-r--r--src/lib/hints.cc2
-rw-r--r--src/lib/player.cc2
-rw-r--r--src/wx/timeline.cc2
8 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 6324050ec..f13201b93 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -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();
+}
+
diff --git a/src/lib/content.h b/src/lib/content.h
index f2fecddf0..540abdd8a 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -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;
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index bdd5e0e09..6e573c639 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -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
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc
index 17f0e73b5..727dcbf26 100644
--- a/src/lib/dcp_decoder.cc
+++ b/src/lib/dcp_decoder.cc
@@ -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) {
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index e0d9918b2..019e4f95c 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -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);
}
diff --git a/src/lib/hints.cc b/src/lib/hints.cc
index bbd5ae5d5..2e2a8fd7b 100644
--- a/src/lib/hints.cc
+++ b/src/lib/hints.cc
@@ -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()) {
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 27c89a2fa..47067af5a 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -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();
}
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index 38e9de4ee..2789d2a54 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -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));
}