Stop jobs silently failing in tests.
[dcpomatic.git] / test / player_test.cc
index 7e2631cc98da0337f445ff27565eeec031c5bb28..15bdb617fbb99c26f6da3495d183cf1564230965 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>
@@ -67,7 +68,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 +99,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 +110,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";
@@ -317,3 +318,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 ();
+}