X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=ee03a1579c59bfe399927fb76a85e316fba21edb;hb=89aa9d4ba69e471949f791cdafe4ae20cea554d2;hp=114e2ebb4c509b5c52fa975a66ba1907021a1882;hpb=936ff6927ad24daf0ed20776b19b6faa3df9bf83;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 114e2ebb4..ee03a1579 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,19 +19,39 @@ */ #include "decoder.h" -#include "decoder_part.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) +ContentTime +Decoder::position () const { - if (position && (time >= position.get() && time < (position.get() + ContentTime::from_seconds(1)))) { - /* No need to seek: caller should just pass() */ - return; + optional pos; + + if (video && (!pos || video->position() < *pos)) { + pos = video->position(); + } + + if (audio && (!pos || audio->position() < *pos)) { + pos = audio->position(); + } + + if (subtitle && (!pos || subtitle->position() < *pos)) { + pos = subtitle->position(); } - seek (time, accurate); + return pos.get_value_or(ContentTime()); +} + +void +Decoder::seek (ContentTime time, bool accurate) +{ + if (audio) { + audio->seek (); + } }