Add failing test for #2364.
authorCarl Hetherington <cth@carlh.net>
Mon, 14 Nov 2022 23:35:20 +0000 (00:35 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 Nov 2022 23:47:36 +0000 (00:47 +0100)
src/lib/audio_analyser.cc
test/audio_analysis_test.cc

index c9fc2118c13276c0f78e810c6bb52bf53b20dd3f..e4dfc6bdeeea6744adee49a3e07534f5b71c9d43 100644 (file)
@@ -138,6 +138,11 @@ AudioAnalyser::analyse (shared_ptr<AudioBuffers> b, DCPTime time)
 {
        LOG_DEBUG_AUDIO_ANALYSIS("Received %1 frames at %2", b->frames(), to_string(time));
        DCPOMATIC_ASSERT (time >= _start);
+       /* In bug #2364 we had a lot of frames arriving here (~47s worth) which
+        * caused an OOM error on Windows.  Check for the number of frames being
+        * reasonable here to make sure we catch this if it happens again.
+        */
+       DCPOMATIC_ASSERT(b->frames() < 480000);
 
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
        if (Config::instance()->analyse_ebur128 ()) {
index 8162d540c1a87aff46af4eff0e780ee161f146c0..b3c519f2934963a8001da3c258cbbcf1d58633a5 100644 (file)
@@ -218,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());
+}