Increase fudge factor at the boundary between audio signal and silence.
authorCarl Hetherington <cth@carlh.net>
Fri, 1 Nov 2019 10:25:20 +0000 (11:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 1 Nov 2019 10:25:20 +0000 (11:25 +0100)
src/lib/player.cc
test/data
test/player_test.cc

index b3fba1aece638df97a57b522f9fda0f31cd352ba..2bf9b186047edcab6bc6cea8f73acdec7d8e0d74 100644 (file)
@@ -648,12 +648,15 @@ Player::pass ()
                if (_last_audio_time) {
                        /* Sometimes the thing that happened last finishes fractionally before
                           or after this silence.  Bodge the start time of the silence to fix it.
                if (_last_audio_time) {
                        /* Sometimes the thing that happened last finishes fractionally before
                           or after this silence.  Bodge the start time of the silence to fix it.
+                          I think is nothing too bad to worry about since we will just add or
+                          remove a little silence at the end of some content.
                        */
                        int64_t const error = labs(period.from.get() - _last_audio_time->get());
                        */
                        int64_t const error = labs(period.from.get() - _last_audio_time->get());
-                       if (error >= 2) {
+                       int64_t const too_much_error = 4;
+                       if (error >= too_much_error) {
                                _film->log()->log(String::compose("Silence starting before or after last audio by %1", error), LogEntry::TYPE_ERROR);
                        }
                                _film->log()->log(String::compose("Silence starting before or after last audio by %1", error), LogEntry::TYPE_ERROR);
                        }
-                       DCPOMATIC_ASSERT (error < 2);
+                       DCPOMATIC_ASSERT (error < too_much_error);
                        period.from = *_last_audio_time;
                }
                if (period.duration() > one_video_frame()) {
                        period.from = *_last_audio_time;
                }
                if (period.duration() > one_video_frame()) {
index eda45cf0736a897f944a8c38e9aed9ca98d4c3ce..6ca8ac639cd63e909237badb5b564e09d54ee90e 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit eda45cf0736a897f944a8c38e9aed9ca98d4c3ce
+Subproject commit 6ca8ac639cd63e909237badb5b564e09d54ee90e
index a7e944cd4b0fbe57e62a414d7270d6eafc5c5068..30b1a56dde93083ce6488f79e838142af2e953dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -344,3 +344,17 @@ BOOST_AUTO_TEST_CASE (player_trim_crash)
 
        butler->rethrow ();
 }
 
        butler->rethrow ();
 }
+
+/** 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)
+{
+       shared_ptr<Film> film = new_test_film2 ("player_silence_crash");
+       shared_ptr<Content> 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 ();
+       film->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+}