Probably makes sense to default to checking KDM validity ranges
[dcpomatic.git] / src / lib / audio_content.cc
index 909f890242dd68fbc91c5461c722a64c0456e16e..59ba992ad2058a7117bc0f29ed128a755fb1b2ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -146,6 +146,8 @@ AudioContent::technical_summary () const
 void
 AudioContent::set_mapping (AudioMapping mapping)
 {
+       ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
        int c = 0;
        BOOST_FOREACH (AudioStreamPtr i, streams ()) {
                AudioMapping stream_mapping (i->channels (), MAX_DCP_AUDIO_CHANNELS);
@@ -157,8 +159,6 @@ AudioContent::set_mapping (AudioMapping mapping)
                }
                i->set_mapping (stream_mapping);
        }
-
-       _parent->signal_changed (AudioContentProperty::STREAMS);
 }
 
 AudioMapping
@@ -250,14 +250,14 @@ AudioContent::processing_description () const
        }
 
        if (not_resampled && resampled) {
-               return String::compose (_("Some audio will be resampled to %1kHz"), resampled_frame_rate ());
+               return String::compose (_("Some audio will be resampled to %1Hz"), resampled_frame_rate ());
        }
 
        if (!not_resampled && resampled) {
                if (same) {
-                       return String::compose (_("Audio will be resampled from %1kHz to %2kHz"), common_frame_rate.get(), resampled_frame_rate ());
+                       return String::compose (_("Audio will be resampled from %1Hz to %2Hz"), common_frame_rate.get(), resampled_frame_rate ());
                } else {
-                       return String::compose (_("Audio will be resampled to %1kHz"), resampled_frame_rate ());
+                       return String::compose (_("Audio will be resampled to %1Hz"), resampled_frame_rate ());
                }
        }
 
@@ -341,12 +341,12 @@ AudioContent::add_properties (list<UserProperty>& p) const
 void
 AudioContent::set_streams (vector<AudioStreamPtr> streams)
 {
+       ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _streams = streams;
        }
-
-       _parent->signal_changed (AudioContentProperty::STREAMS);
 }
 
 AudioStreamPtr
@@ -360,31 +360,31 @@ AudioContent::stream () const
 void
 AudioContent::add_stream (AudioStreamPtr stream)
 {
+       ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _streams.push_back (stream);
        }
-
-       _parent->signal_changed (AudioContentProperty::STREAMS);
 }
 
 void
 AudioContent::set_stream (AudioStreamPtr stream)
 {
+       ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _streams.clear ();
                _streams.push_back (stream);
        }
-
-       _parent->signal_changed (AudioContentProperty::STREAMS);
 }
 
 void
-AudioContent::use_template (shared_ptr<const AudioContent> c)
+AudioContent::take_settings_from (shared_ptr<const AudioContent> c)
 {
-       _gain = c->_gain;
-       _delay = c->_delay;
+       set_gain (c->_gain);
+       set_delay (c->_delay);
 
        size_t i = 0;
        size_t j = 0;
@@ -395,3 +395,17 @@ AudioContent::use_template (shared_ptr<const AudioContent> c)
                ++j;
        }
 }
+
+void
+AudioContent::modify_position (DCPTime& pos) const
+{
+       pos = pos.round (_parent->film()->audio_frame_rate());
+}
+
+void
+AudioContent::modify_trim_start (ContentTime& trim) const
+{
+       DCPOMATIC_ASSERT (!_streams.empty());
+       /* XXX: we're in trouble if streams have different rates */
+       trim = trim.round (_streams.front()->frame_rate());
+}