Add basic memory-used stuff for butler and reduce minimum audio
[dcpomatic.git] / src / lib / text_subtitle_decoder.cc
index bdec17a8dba0a7ad386ba9f3b2e676ca881d7885..6188d524f97b101344138f83bacfaaa14dacc13b 100644 (file)
@@ -38,12 +38,24 @@ TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr<const TextSubtitleContent>
        : TextSubtitle (content)
        , _next (0)
 {
-       subtitle.reset (new SubtitleDecoder (this, content->subtitle, log));
+       ContentTime first;
+       if (!_subtitles.empty()) {
+               first = content_time_period(_subtitles[0]).from;
+       }
+       subtitle.reset (new SubtitleDecoder (this, content->subtitle, log, first));
 }
 
 void
 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;