Bump test digest.
[dcpomatic.git] / test / player_test.cc
index 7e2631cc98da0337f445ff27565eeec031c5bb28..7b65783c6047dcfd646b1cae21e44bbc3550a531 100644 (file)
@@ -37,6 +37,7 @@
 #include "lib/text_content.h"
 #include "lib/butler.h"
 #include "lib/compose.hpp"
+#include "lib/cross.h"
 #include "test.h"
 #include <boost/test/unit_test.hpp>
 #include <iostream>
@@ -47,6 +48,7 @@ using std::pair;
 using boost::shared_ptr;
 using boost::bind;
 using boost::optional;
+using namespace dcpomatic;
 
 static shared_ptr<AudioBuffers> accumulated;
 
@@ -67,7 +69,7 @@ BOOST_AUTO_TEST_CASE (player_silence_padding_test)
        film->set_audio_channels (6);
 
        film->examine_and_add_content (c);
-       wait_for_jobs ();
+       BOOST_REQUIRE (!wait_for_jobs());
 
        accumulated.reset (new AudioBuffers (film->audio_channels(), 0));
 
@@ -98,7 +100,7 @@ BOOST_AUTO_TEST_CASE (player_black_fill_test)
 
        film->examine_and_add_content (contentA);
        film->examine_and_add_content (contentB);
-       wait_for_jobs ();
+       BOOST_REQUIRE (!wait_for_jobs());
 
        contentA->video->set_scale (VideoContentScale (Ratio::from_id ("185")));
        contentA->video->set_length (3);
@@ -109,7 +111,7 @@ BOOST_AUTO_TEST_CASE (player_black_fill_test)
 
        film->make_dcp ();
 
-       wait_for_jobs ();
+       BOOST_REQUIRE (!wait_for_jobs());
 
        boost::filesystem::path ref;
        ref = "test";
@@ -221,11 +223,11 @@ BOOST_AUTO_TEST_CASE (player_seek_test)
                pair<shared_ptr<PlayerVideo>, DCPTime> video = butler->get_video();
                BOOST_CHECK_EQUAL(video.second.get(), t.get());
                write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true), String::compose("build/test/player_seek_test_%1.png", i), "RGB");
-               /* This 0.011 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine
+               /* This 0.055 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine
                   (17.10 and 16.04 seem to anti-alias a little differently) but to reject gross errors e.g. missing fonts or missing
                   text altogether.
                */
-               check_image(String::compose("test/data/player_seek_test_%1.png", i), String::compose("build/test/player_seek_test_%1.png", i), 0.011);
+               check_image(String::compose("test/data/player_seek_test_%1.png", i), String::compose("build/test/player_seek_test_%1.png", i), 0.055);
        }
 }
 
@@ -254,7 +256,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test2)
                pair<shared_ptr<PlayerVideo>, DCPTime> video = butler->get_video();
                BOOST_CHECK_EQUAL(video.second.get(), t.get());
                write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true), String::compose("build/test/player_seek_test2_%1.png", i), "RGB");
-               check_image(String::compose("test/data/player_seek_test2_%1.png", i), String::compose("build/test/player_seek_test2_%1.png", i), 0.011);
+               check_image(String::compose("test/data/player_seek_test2_%1.png", i), String::compose("build/test/player_seek_test2_%1.png", i), 0.055);
        }
 }
 
@@ -317,3 +319,28 @@ BOOST_AUTO_TEST_CASE (player_ignore_video_and_audio_test)
 
        BOOST_CHECK_EQUAL (out.size(), 6);
 }
+
+/** Trigger a crash due to the assertion failure in Player::emit_audio */
+BOOST_AUTO_TEST_CASE (player_trim_crash)
+{
+       shared_ptr<Film> film = new_test_film2 ("player_trim_crash");
+       shared_ptr<Content> boon = content_factory(private_data / "boon_telly.mkv").front();
+       film->examine_and_add_content (boon);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       shared_ptr<Player> player (new Player(film, film->playlist()));
+       player->set_fast ();
+       shared_ptr<Butler> butler (new Butler(player, AudioMapping(), 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true));
+
+       /* Wait for the butler to fill */
+       dcpomatic_sleep (5);
+
+       boon->set_trim_start (ContentTime::from_seconds(5));
+
+       butler->seek (DCPTime(), true);
+
+       /* Wait for the butler to refill */
+       dcpomatic_sleep (5);
+
+       butler->rethrow ();
+}