X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fdecoder.cc;h=502273de1e49f5a551110674a5d8284572dbe180;hb=160a401d16e3962b10f3105e00992936a8188424;hp=988b8fe9b2f9fc73a6261064e673396365f71bdf;hpb=f113b2aaca7a65f7b37e12a7d9f3f99e2d834e81;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 988b8fe9b..502273de1 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,24 +19,46 @@ */ #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 (video && !video->ignore() && (!pos || video->position() < *pos)) { + pos = video->position(); + } + + if (audio && !audio->ignore() && (!pos || audio->position() < *pos)) { + pos = audio->position(); } - if (time >= *position && time < (*position + ContentTime::from_seconds(1))) { - /* No need to seek: caller should just pass() */ - return; + if (subtitle && !subtitle->ignore() && (!pos || subtitle->position() < *pos)) { + pos = subtitle->position(); } - position.reset (); - seek (time, accurate); + return pos.get_value_or(ContentTime()); +} + +void +Decoder::seek (ContentTime, bool) +{ + if (video) { + video->seek (); + } + if (audio) { + audio->seek (); + } + if (subtitle) { + subtitle->seek (); + } }