X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=0d4f4babfa9db0831650529ae4ead927260dc7f3;hb=35e9a698ba3ca35fd488b3622e441956632261cf;hp=50356da788e84c018f175e6c611a6d5a6313f52b;hpb=24e890682b3f2aa211277ad8b6b3591f2026d4be;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 50356da78..0d4f4babf 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This file is part of DCP-o-matic. @@ -19,42 +19,43 @@ */ #include "decoder.h" +#include "video_decoder.h" +#include "audio_decoder.h" +#include "subtitle_decoder.h" +#include #include using std::cout; using boost::optional; -void -Decoder::maybe_seek (optional& position, ContentTime time, bool accurate) +/** @return Earliest time of content that the next pass() will emit */ +ContentTime +Decoder::position () const { - if (!position) { - /* A seek has just happened */ - return; - } + optional pos; - if (time >= *position && time < (*position + ContentTime::from_seconds(1))) { - /* No need to seek: caller should just pass() */ - return; + if (video && !video->ignore() && (!pos || video->position() < *pos)) { + pos = video->position(); } - position.reset (); - seek (time, accurate); -} + if (audio && !audio->ignore() && (!pos || audio->position() < *pos)) { + pos = audio->position(); + } -void -Decoder::maybe_seek_video (ContentTime time, bool accurate) -{ - maybe_seek (_video_position, time, accurate); -} + if (subtitle && !subtitle->ignore() && (!pos || subtitle->position() < *pos)) { + pos = subtitle->position(); + } -void -Decoder::maybe_seek_audio (ContentTime time, bool accurate) -{ - maybe_seek (_audio_position, time, accurate); + return pos.get_value_or(ContentTime()); } void -Decoder::maybe_seek_subtitle (ContentTime time, bool accurate) +Decoder::seek (ContentTime, bool) { - maybe_seek (_subtitle_position, time, accurate); + if (audio) { + audio->seek (); + } + if (subtitle) { + subtitle->seek (); + } }