Fix seeking; seek all decoders even if they have no content at the
authorCarl Hetherington <cth@carlh.net>
Sun, 23 Apr 2017 22:08:37 +0000 (23:08 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 23 Apr 2017 22:08:37 +0000 (23:08 +0100)
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

index e59451abece83bf7001930b02c621873eb5a6ac1..28c8fc7f7ab78230ac4ab24e1af46590ac285765 100644 (file)
@@ -623,8 +623,8 @@ Player::video (weak_ptr<Piece> 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<Piece> 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) {