Add video_{range,frame_type}.{cc,h} and remove some types.h includes.
[dcpomatic.git] / src / lib / audio_content.cc
index 82a6a84d1d38d90c875371b9592d9f16d3d7305a..1fcd335839926f2d77cea716c701ebc666035af0 100644 (file)
@@ -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<ContentTime::Type>("AudioFadeIn").get_value_or(0));
        _fade_out = ContentTime(node->optional_number_child<ContentTime::Type>("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<double>("AudioVideoFrameRate");
-       if (r) {
-               _parent->set_video_frame_rate (r.get());
-       }
 }
 
 
@@ -426,11 +421,13 @@ AudioContent::modify_position (shared_ptr<const Film> film, DCPTime& pos) const
 
 
 void
-AudioContent::modify_trim_start (ContentTime& trim) const
+AudioContent::modify_trim_start(shared_ptr<const Film> 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);
 }