X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=0d4f4babfa9db0831650529ae4ead927260dc7f3;hb=35e9a698ba3ca35fd488b3622e441956632261cf;hp=785fb96f0c2ed4b0b7637abba296bcbb61ca40b1;hpb=de2af791bdfdcd653752cba970e59efc7bf810c7;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 785fb96f0..0d4f4babf 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -22,23 +22,40 @@ #include "video_decoder.h" #include "audio_decoder.h" #include "subtitle_decoder.h" +#include +#include +using std::cout; +using boost::optional; + +/** @return Earliest time of content that the next pass() will emit */ ContentTime Decoder::position () const { - ContentTime pos; + optional pos; - if (video && video->position()) { - pos = min (pos, video->position().get()); + if (video && !video->ignore() && (!pos || video->position() < *pos)) { + pos = video->position(); } - if (audio && audio->position()) { - pos = min (pos, audio->position().get()); + if (audio && !audio->ignore() && (!pos || audio->position() < *pos)) { + pos = audio->position(); } - if (subtitle && subtitle->position()) { - pos = min (pos, subtitle->position().get()); + if (subtitle && !subtitle->ignore() && (!pos || subtitle->position() < *pos)) { + pos = subtitle->position(); } - return pos; + return pos.get_value_or(ContentTime()); +} + +void +Decoder::seek (ContentTime, bool) +{ + if (audio) { + audio->seek (); + } + if (subtitle) { + subtitle->seek (); + } }