Fix audio glitches when merging resampled audio (#2373).
authorCarl Hetherington <cth@carlh.net>
Tue, 22 Nov 2022 01:16:40 +0000 (02:16 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 25 Nov 2022 23:09:27 +0000 (00:09 +0100)
src/lib/audio_content.cc

index 05c388a3e711812dc3ad3ceef1c39d8b01002edd..acd3b81b4295e817d54de91c9f3787b144b95886 100644 (file)
@@ -422,9 +422,11 @@ AudioContent::modify_position (shared_ptr<const Film> film, DCPTime& pos) const
 void
 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);
 }