Comment.
[dcpomatic.git] / src / lib / text_subtitle_decoder.cc
index 51a747fa9343b66d11a6472ff2b6d833aee13530..846c3016ee1748f8c97aa08b27a1232ed3a8ec57 100644 (file)
@@ -42,26 +42,36 @@ TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr<const TextSubtitleContent>
 }
 
 void
-TextSubtitleDecoder::seek (ContentTime time, bool)
+TextSubtitleDecoder::seek (ContentTime time, bool accurate)
 {
+       /* It's worth back-tracking a little here as decoding is cheap and it's nice if we don't miss
+          too many subtitles when seeking.
+       */
+       time -= ContentTime::from_seconds (5);
+       if (time < ContentTime()) {
+               time = ContentTime();
+       }
+
+       Decoder::seek (time, accurate);
+
        _next = 0;
        while (_next < _subtitles.size() && ContentTime::from_seconds (_subtitles[_next].from.all_as_seconds ()) < time) {
                ++_next;
        }
 }
 
-void
+bool
 TextSubtitleDecoder::pass ()
 {
        if (_next >= _subtitles.size ()) {
-               return;
+               return true;
        }
 
        ContentTimePeriod const p = content_time_period (_subtitles[_next]);
        subtitle->emit_text (p, _subtitles[_next]);
 
        ++_next;
-       return;
+       return false;
 }
 
 ContentTimePeriod