X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Faudio_content.cc;h=be81d46d618e6c884dc30650fa01f9eccc6bfeff;hb=ef207d932aff9e873766861e373e4c910ea161da;hp=5098e84898cdf04e9aec2894b070dbb60722e253;hpb=fdb36750a09e3bba3d10fe5102e39a62eda68ea6;p=dcpomatic.git diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 5098e8489..be81d46d6 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -22,6 +22,7 @@ #include "audio_content.h" #include "compose.hpp" #include "config.h" +#include "constants.h" #include "exceptions.h" #include "film.h" #include "frame_rate_change.h" @@ -97,12 +98,6 @@ AudioContent::AudioContent (Content* parent, cxml::ConstNodePtr node) _fade_in = ContentTime(node->optional_number_child("AudioFadeIn").get_value_or(0)); _fade_out = ContentTime(node->optional_number_child("AudioFadeOut").get_value_or(0)); _use_same_fades_as_video = node->optional_bool_child("AudioUseSameFadesAsVideo").get_value_or(false); - - /* Backwards compatibility */ - auto r = node->optional_number_child("AudioVideoFrameRate"); - if (r) { - _parent->set_video_frame_rate (r.get()); - } } @@ -318,7 +313,10 @@ AudioContent::add_properties (shared_ptr film, list& p if (stream) { p.push_back (UserProperty(UserProperty::AUDIO, _("Channels"), stream->channels())); - p.push_back (UserProperty(UserProperty::AUDIO, _("Content audio sample rate"), stream->frame_rate(), _("Hz"))); + p.push_back (UserProperty(UserProperty::AUDIO, _("Content sample rate"), stream->frame_rate(), _("Hz"))); + if (auto bits = stream->bit_depth()) { + p.push_back(UserProperty(UserProperty::AUDIO, _("Content bit depth"), *bits, _("bits"))); + } } FrameRateChange const frc (_parent->active_video_frame_rate(film), film->video_frame_rate()); @@ -353,18 +351,6 @@ AudioContent::add_properties (shared_ptr film, list& p } -void -AudioContent::set_streams (vector streams) -{ - ContentChangeSignaller cc (_parent, AudioContentProperty::STREAMS); - - { - boost::mutex::scoped_lock lm (_mutex); - _streams = streams; - } -} - - AudioStreamPtr AudioContent::stream () const { @@ -404,14 +390,15 @@ AudioContent::take_settings_from (shared_ptr c) { set_gain (c->_gain); set_delay (c->_delay); + set_fade_in (c->fade_in()); + set_fade_out (c->fade_out()); - size_t i = 0; - size_t j = 0; + auto const streams_to_take = std::min(_streams.size(), c->_streams.size()); - while (i < _streams.size() && j < c->_streams.size()) { - _streams[i]->set_mapping (c->_streams[j]->mapping()); - ++i; - ++j; + for (auto i = 0U; i < streams_to_take; ++i) { + auto mapping = _streams[i]->mapping(); + mapping.take_from(c->_streams[i]->mapping()); + _streams[i]->set_mapping(mapping); } } @@ -424,11 +411,13 @@ AudioContent::modify_position (shared_ptr film, DCPTime& pos) const void -AudioContent::modify_trim_start (ContentTime& trim) const +AudioContent::modify_trim_start(shared_ptr film, ContentTime& trim) const { - DCPOMATIC_ASSERT (!_streams.empty()); - /* XXX: we're in trouble if streams have different rates */ - trim = trim.round (_streams.front()->frame_rate()); + /* When this trim is used it the audio will have been resampled, and using the + * DCP rate here reduces the chance of rounding errors causing audio glitches + * due to errors in placement of audio frames (#2373). + */ + trim = trim.round(film ? film->audio_frame_rate() : 48000); }