summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-02-18 23:36:10 +0100
committerCarl Hetherington <cth@carlh.net>2024-02-19 09:54:43 +0100
commit167ff6413dcc32680b2b778303f659656c2a51df (patch)
tree757df02b914e53d89d49ae3cd3300e8568942ff1
parentd36b320c0a3d0ba0951eea486578275b3738a687 (diff)
Reset _next_video_time when deciding to emit black.
Otherwise if we inaccurately seek into an area with no video there will never be any content coming into ::video() which could reset _next_video_time. Then when a black frame is emitted using emit_video_until we will emit black frames from time 0 to the time of the inaccurate seek.
-rw-r--r--src/lib/player.cc6
-rw-r--r--test/player_test.cc29
2 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 6f9b70d0a..03935a46b 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -774,6 +774,12 @@ Player::pass ()
}
case BLACK:
LOG_DEBUG_PLAYER ("Emit black for gap at %1", to_string(_black.position()));
+ if (!_next_video_time) {
+ /* Deciding to emit black has the same effect as getting some video from the content
+ * when we are inaccurately seeking.
+ */
+ _next_video_time = _black.position();
+ }
if (film->three_d()) {
use_video(black_player_video_frame(Eyes::LEFT), _black.position(), _black.period_at_position().to);
use_video(black_player_video_frame(Eyes::RIGHT), _black.position(), _black.period_at_position().to);
diff --git a/test/player_test.cc b/test/player_test.cc
index 5120c0180..530dfc770 100644
--- a/test/player_test.cc
+++ b/test/player_test.cc
@@ -54,6 +54,7 @@ using std::cout;
using std::list;
using std::shared_ptr;
using std::make_shared;
+using std::vector;
using boost::bind;
using boost::optional;
#if BOOST_VERSION >= 106100
@@ -710,3 +711,31 @@ BOOST_AUTO_TEST_CASE(three_d_in_two_d_chooses_left)
while (!player->pass()) {}
}
+
+BOOST_AUTO_TEST_CASE(check_seek_with_no_video)
+{
+ auto content = content_factory(TestPaths::private_data() / "Fight.Club.1999.720p.BRRip.x264-x0r.srt")[0];
+ auto film = new_test_film2("check_seek_with_no_video", { content });
+ auto player = std::make_shared<Player>(film, film->playlist());
+
+ boost::signals2::signal<void (std::shared_ptr<PlayerVideo>, dcpomatic::DCPTime)> Video;
+
+ optional<dcpomatic::DCPTime> earliest;
+
+ player->Video.connect(
+ [&earliest](shared_ptr<PlayerVideo>, dcpomatic::DCPTime time) {
+ if (!earliest || time < *earliest) {
+ earliest = time;
+ }
+ });
+
+ player->seek(dcpomatic::DCPTime::from_seconds(60 * 60), false);
+
+ for (int i = 0; i < 10; ++i) {
+ player->pass();
+ }
+
+ BOOST_REQUIRE(earliest);
+ BOOST_CHECK(*earliest >= dcpomatic::DCPTime(60 * 60));
+}
+