Extract constants.h
[dcpomatic.git] / test / audio_analysis_test.cc
index e131ce57c9cf331650302488f95d0dcce0adc183..b3c519f2934963a8001da3c258cbbcf1d58633a5 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 
-#include "test.h"
 #include "lib/analyse_audio_job.h"
 #include "lib/audio_analysis.h"
 #include "lib/audio_content.h"
@@ -39,8 +38,8 @@
 #include "lib/job_manager.h"
 #include "lib/playlist.h"
 #include "lib/ratio.h"
+#include "test.h"
 #include <boost/test/unit_test.hpp>
-#include <iostream>
 
 
 using std::make_shared;
@@ -188,7 +187,7 @@ BOOST_AUTO_TEST_CASE (analyse_audio_test4)
        film->set_container (Ratio::from_id ("185"));
        film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR"));
        film->set_name ("frobozz");
-       auto content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a").front();
+       auto content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a")[0];
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
 
@@ -204,7 +203,7 @@ BOOST_AUTO_TEST_CASE (analyse_audio_leqm_test)
 {
        auto film = new_test_film2 ("analyse_audio_leqm_test");
        film->set_audio_channels (2);
-       auto content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav").front();
+       auto content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav")[0];
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
 
@@ -219,3 +218,19 @@ BOOST_AUTO_TEST_CASE (analyse_audio_leqm_test)
        /* The CLI tool of leqm_nrt gives this value for betty_stereo_48k.wav */
        BOOST_CHECK_CLOSE (analysis.leqm().get_value_or(0), 88.276, 0.001);
 }
+
+
+/** Bug #2364; a file with a lot of silent video at the end (about 50s worth)
+ *  crashed the audio analysis with an OOM on Windows.
+ */
+BOOST_AUTO_TEST_CASE(analyse_audio_with_long_silent_end)
+{
+       auto content = content_factory(TestPaths::private_data() / "2364.mkv")[0];
+       auto film = new_test_film2("analyse_audio_with_long_silent_end", { content });
+
+       auto playlist = make_shared<Playlist>();
+       playlist->add(film, content);
+       boost::signals2::connection c;
+       JobManager::instance()->analyse_audio(film, playlist, false, c, []() {});
+       BOOST_CHECK(!wait_for_jobs());
+}