Fix assertion failure on making a VF, in certain circumstances.
authorCarl Hetherington <cth@carlh.net>
Tue, 15 Oct 2019 22:04:53 +0000 (22:04 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 15 Oct 2019 22:07:59 +0000 (00:07 +0200)
These circumstances were a VF which refers to at least one complete
reel of audio from a OV before adding more audio of its own.

Forward-porter from 392d675f5799671abbcf1a9a47820321bcbdcca2 in master.

src/lib/writer.cc
test/reels_test.cc

index 9a0f83a22a5c184d68c3b5c5bc07789fe9fe3bca..915376055b31f9f55561dc7a5ca6b48fa44746a9 100644 (file)
@@ -269,8 +269,11 @@ Writer::write (shared_ptr<const AudioBuffers> audio, DCPTime const time)
                        /* Easy case: we can write all the audio to this reel */
                        _audio_reel->write (audio);
                        t = end;
+               } else if (_audio_reel->period().to <= t) {
+                       /* This reel is entirely before the start of our audio; just skip the reel */
+                       ++_audio_reel;
                } else {
-                       /* Split the audio into two and write the first part */
+                       /* This audio is over a reel boundary; split the audio into two and write the first part */
                        DCPTime part_lengths[2] = {
                                _audio_reel->period().to - t,
                                end - _audio_reel->period().to
index 15e386d59c29b679616443563882db3289794ec9..620c934178723f21d421e458630686e23e4a9708 100644 (file)
@@ -372,3 +372,44 @@ BOOST_AUTO_TEST_CASE (reels_test9)
        film2->make_dcp();
        BOOST_REQUIRE(!wait_for_jobs());
 }
+
+/** Another reels-related error; make_dcp() would raise a ProgrammingError
+ *  in AudioBuffers::allocate due to an attempt to allocate a negatively-sized buffer.
+ *  This was triggered by a VF where there are referenced audio reels followed by
+ *  VF audio.  When the VF audio arrives the Writer did not correctly skip over the
+ *  referenced reels.
+ */
+BOOST_AUTO_TEST_CASE (reels_test10)
+{
+       /* Make the OV */
+       shared_ptr<Film> ov = new_test_film2("reels_test10_ov");
+       shared_ptr<FFmpegContent> A(new FFmpegContent("test/data/flat_red.png"));
+       ov->examine_and_add_content (A);
+       BOOST_REQUIRE (!wait_for_jobs());
+       A->video->set_length (5 * 24);
+
+       shared_ptr<FFmpegContent> B(new FFmpegContent("test/data/flat_red.png"));
+       ov->examine_and_add_content (B);
+       BOOST_REQUIRE (!wait_for_jobs());
+       B->video->set_length (5 * 24);
+
+       ov->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
+       ov->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+       ov->write_metadata ();
+
+       /* Now try to make the VF; this used to fail */
+       shared_ptr<Film> vf = new_test_film2("reels_test10_vf");
+       shared_ptr<DCPContent> ov_dcp(new DCPContent(ov->dir(ov->dcp_name())));
+       vf->examine_and_add_content (ov_dcp);
+       BOOST_REQUIRE (!wait_for_jobs());
+       vf->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
+       ov_dcp->set_reference_video (true);
+       ov_dcp->set_reference_audio (true);
+       vf->examine_and_add_content (content_factory("test/data/15s.srt").front());
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       vf->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+       vf->write_metadata ();
+}