+
+
+/** Test a crash when the gap between the last audio and the start of a silent period is more than 1 sample */
+BOOST_AUTO_TEST_CASE (player_silence_crash)
+{
+ auto film = new_test_film2 ("player_silence_crash");
+ auto sine = content_factory("test/data/impulse_train.wav").front();
+ film->examine_and_add_content (sine);
+ BOOST_REQUIRE (!wait_for_jobs());
+
+ sine->set_video_frame_rate (23.976);
+ film->write_metadata ();
+ make_and_verify_dcp (film, {dcp::VerificationNote::Code::MISSING_CPL_METADATA});
+}
+
+
+/** Test a crash when processing a 3D DCP */
+BOOST_AUTO_TEST_CASE (player_3d_test_1)
+{
+ auto film = new_test_film2 ("player_3d_test_1a");
+ auto left = content_factory("test/data/flat_red.png").front();
+ film->examine_and_add_content (left);
+ auto right = content_factory("test/data/flat_blue.png").front();
+ film->examine_and_add_content (right);
+ BOOST_REQUIRE (!wait_for_jobs());
+
+ left->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
+ left->set_position (film, DCPTime());
+ right->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
+ right->set_position (film, DCPTime());
+ film->set_three_d (true);
+
+ make_and_verify_dcp (film);
+
+ auto dcp = std::make_shared<DCPContent>(film->dir(film->dcp_name()));
+ auto film2 = new_test_film2 ("player_3d_test_1b", {dcp});
+
+ film2->set_three_d (true);
+ make_and_verify_dcp (film2);
+}
+
+
+/** Test a crash when processing a 3D DCP as content in a 2D project */
+BOOST_AUTO_TEST_CASE (player_3d_test_2)
+{
+ auto left = content_factory("test/data/flat_red.png").front();
+ auto right = content_factory("test/data/flat_blue.png").front();
+ auto film = new_test_film2 ("player_3d_test_2a", {left, right});
+
+ left->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
+ left->set_position (film, DCPTime());
+ right->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
+ right->set_position (film, DCPTime());
+ film->set_three_d (true);
+
+ make_and_verify_dcp (film);
+
+ auto dcp = std::make_shared<DCPContent>(film->dir(film->dcp_name()));
+ auto film2 = new_test_film2 ("player_3d_test_2b", {dcp});
+
+ make_and_verify_dcp (film2);
+}
+
+
+/** Test a crash when there is video-only content at the end of the DCP and a frame-rate conversion is happening;
+ * #1691.
+ */
+BOOST_AUTO_TEST_CASE (player_silence_at_end_crash)
+{
+ /* 25fps DCP with some audio */
+ auto content1 = content_factory("test/data/flat_red.png").front();
+ auto film1 = new_test_film2 ("player_silence_at_end_crash_1", {content1});
+ content1->video->set_length (25);
+ film1->set_video_frame_rate (25);
+ make_and_verify_dcp (film1);
+
+ /* Make another project importing this DCP */
+ auto content2 = std::make_shared<DCPContent>(film1->dir(film1->dcp_name()));
+ auto film2 = new_test_film2 ("player_silence_at_end_crash_2", {content2});
+
+ /* and importing just the video MXF on its own at the end */
+ optional<boost::filesystem::path> video;
+ for (auto i: boost::filesystem::directory_iterator(film1->dir(film1->dcp_name()))) {
+ if (boost::starts_with(i.path().filename().string(), "j2c_")) {
+ video = i.path();
+ }
+ }
+
+ BOOST_REQUIRE (video);
+ auto content3 = content_factory(*video).front();
+ film2->examine_and_add_content (content3);
+ BOOST_REQUIRE (!wait_for_jobs());
+ content3->set_position (film2, DCPTime::from_seconds(1.5));
+ film2->set_video_frame_rate (24);
+ make_and_verify_dcp (film2);
+}