Fix up black-filling logic.
[dcpomatic.git] / src / lib / decoder.cc
index 114e2ebb4c509b5c52fa975a66ba1907021a1882..1b281f718fe68e7dfc65d906171ebe1a3a2a4c6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 */
 
 #include "decoder.h"
-#include "decoder_part.h"
+#include "video_decoder.h"
+#include "audio_decoder.h"
+#include "subtitle_decoder.h"
+#include <boost/optional.hpp>
 #include <iostream>
 
 using std::cout;
 using boost::optional;
 
-void
-Decoder::maybe_seek (optional<ContentTime> position, ContentTime time, bool accurate)
+/** @return Earliest time of content that the next pass() will emit */
+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<ContentTime> 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, bool)
+{
+       if (audio) {
+               audio->seek ();
+       }
 }