Don't seek a piece if the seek is outside its boundary.
authorCarl Hetherington <cth@carlh.net>
Fri, 5 May 2017 09:19:34 +0000 (10:19 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 5 May 2017 09:19:34 +0000 (10:19 +0100)
src/lib/player.cc

index 7ede96a0daeee117dc09b7ea32b64c20c8dc1b37..3de26ec90fcae36e18f5c07cd62622d525aacaed 100644 (file)
@@ -913,9 +913,18 @@ Player::seek (DCPTime time, bool accurate)
        _active_subtitles.clear ();
 
        BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
-               i->done = false;
-               DCPTime const t = min(max(time, i->content->position()), i->content->end());
-               i->decoder->seek (dcp_to_content_time (i, t), accurate);
+               if (time < i->content->position()) {
+                       /* Before; seek to 0 */
+                       i->decoder->seek (ContentTime(), accurate);
+                       i->done = false;
+               } else if (i->content->position() <= time && time < i->content->end()) {
+                       /* During; seek to position */
+                       i->decoder->seek (dcp_to_content_time (i, time), accurate);
+                       i->done = false;
+               } else {
+                       /* After; this piece is done */
+                       i->done = true;
+               }
        }
 
        if (accurate) {