Give DCPDecoder its own ::position which just returns its internal
authorCarl Hetherington <cth@carlh.net>
Thu, 9 Jan 2020 23:52:20 +0000 (23:52 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 10 Jan 2020 00:01:03 +0000 (01:01 +0100)
_next time.

This is important because Decoder::position does the wrong thing
with DCPs in the following case.

1.  DCPDecoder emits a subtitle event (start/stop) at time t.
2.  There follows a long time T with no subtitle events.  During
    this time the DCPDecoder's position is reported as t (since
    TextDecoder notes its position as the time of the last thing
    it emitted --- which is all it reasonably can do, I think).
3.  During this T the DCPDecoder may be incorrectly pass()ed because
    its position is reported as earlier than it really is; this results
    in video/audio being emitted by the DCPDecoder but other contemporary
    sources may not be pass()ed.

The upshot of this can be that no audio is emitted, as a contemporary audio
source is not pass()ed and hence the merger is waiting for audio that will
take a long time to come.  When the butler is running this can result in
audio underruns as the video buffers overflow with no sign of any audio.

It is also simpler this way; DCPDecoder was already maintaining the required
information.

src/lib/dcp_decoder.cc
src/lib/dcp_decoder.h
src/lib/decoder.h

index a3c42a321a70d824ca8d6a84497dfcec804595c9..03ac66e944aeebfaac1522806d4187e9ceac3966 100644 (file)
@@ -457,3 +457,9 @@ DCPDecoder::calculate_lazy_digest (shared_ptr<const DCPContent> c) const
        }
        return d.get ();
 }
        }
        return d.get ();
 }
+
+ContentTime
+DCPDecoder::position () const
+{
+       return ContentTime::from_frames(_offset, _dcp_content->active_video_frame_rate(film())) + _next;
+}
index 496d95740d63cf26e9c74024dd43f506416cbf7b..4de8c86299a0af3fc096387f6f3ea3bab3a77033 100644 (file)
@@ -62,6 +62,8 @@ public:
                return _lazy_digest;
        }
 
                return _lazy_digest;
        }
 
+       dcpomatic::ContentTime position () const;
+
 private:
        friend struct dcp_subtitle_within_dcp_test;
 
 private:
        friend struct dcp_subtitle_within_dcp_test;
 
index 92082ca18b105a62f9dd9aec909625c12ac875c9..ddea58aacbfc636c9c29d0264300155046c5378b 100644 (file)
@@ -57,7 +57,7 @@ public:
        virtual bool pass () = 0;
        virtual void seek (dcpomatic::ContentTime time, bool accurate);
 
        virtual bool pass () = 0;
        virtual void seek (dcpomatic::ContentTime time, bool accurate);
 
-       dcpomatic::ContentTime position () const;
+       virtual dcpomatic::ContentTime position () const;
 
 protected:
        boost::shared_ptr<const Film> film () const;
 
 protected:
        boost::shared_ptr<const Film> film () const;