Fix DCP playback when an incorrect KDM is added, followed by
[dcpomatic.git] / src / lib / dcp_decoder.cc
index 826b4e8d387ba44d709cb77bff36fe40bda318c5..ab724cd6c75bbb7a5f02326e15b92f3a964a0322 100644 (file)
@@ -29,6 +29,7 @@
 #include "image.h"
 #include "config.h"
 #include "digester.h"
+#include "frame_interval_checker.h"
 #include <dcp/dcp.h>
 #include <dcp/cpl.h>
 #include <dcp/reel.h>
@@ -125,7 +126,14 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
 bool
 DCPDecoder::pass ()
 {
-       if (_reel == _reels.end () || !_dcp_content->can_be_played ()) {
+       if (!_dcp_content->can_be_played()) {
+               return true;
+       }
+
+       if (_reel == _reels.end()) {
+               if (audio) {
+                       audio->flush ();
+               }
                return true;
        }
 
@@ -443,10 +451,18 @@ DCPDecoder::calculate_lazy_digest (shared_ptr<const DCPContent> c) const
        BOOST_FOREACH (boost::filesystem::path i, c->paths()) {
                d.add (i.string());
        }
-       d.add (static_cast<bool>(_dcp_content->kdm()));
+       if (_dcp_content->kdm()) {
+               d.add(_dcp_content->kdm()->id());
+       }
        d.add (static_cast<bool>(c->cpl()));
        if (c->cpl()) {
                d.add (c->cpl().get());
        }
        return d.get ();
 }
+
+ContentTime
+DCPDecoder::position () const
+{
+       return ContentTime::from_frames(_offset, _dcp_content->active_video_frame_rate(film())) + _next;
+}