From d24479e588b88e32bb4cd077d1648b7d043b5e07 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 23 Apr 2017 23:08:37 +0100 Subject: [PATCH] Fix seeking; seek all decoders even if they have no content at the seek position, and make Player cope with the FFmpegDecoder emitting pre-roll data. This seems nicer than making FFmpegDecoder do it. --- src/lib/player.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/player.cc b/src/lib/player.cc index e59451abe..28c8fc7f7 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -623,8 +623,8 @@ Player::video (weak_ptr wp, ContentVideo video) DCPTime const time = content_video_to_dcp (piece, video.frame); DCPTimePeriod const period (time, time + one_video_frame()); - /* Discard if it's outside the content's period */ - if (time < piece->content->position() || time >= piece->content->end()) { + /* Discard if it's outside the content's period or if it's before the last accurate seek */ + if (time < piece->content->position() || time >= piece->content->end() || (_last_video_time && time <= _last_video_time)) { return; } @@ -915,9 +915,8 @@ Player::seek (DCPTime time, bool accurate) BOOST_FOREACH (shared_ptr i, _pieces) { i->done = false; - if (i->content->position() <= time && time < i->content->end()) { - i->decoder->seek (dcp_to_content_time (i, time), accurate); - } + DCPTime const t = min(max(time, i->content->position()), i->content->end()); + i->decoder->seek (dcp_to_content_time (i, t), accurate); } if (accurate) { -- 2.30.2