Remove Piece::_done in favour of a method.
authorCarl Hetherington <cth@carlh.net>
Tue, 4 May 2021 20:14:26 +0000 (22:14 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 May 2021 07:29:59 +0000 (09:29 +0200)
src/lib/piece.cc
src/lib/piece.h

index 452b34222a8459de37af1c19a22b5efe4af6c695..12b62e8246dd9d6a4ea8c3adf4c419cecd4759b6 100644 (file)
@@ -168,7 +168,7 @@ Piece::atmos (shared_ptr<const dcp::AtmosFrame> data, Frame frame, AtmosMetadata
 void
 Piece::update_pull_to (DCPTime& pull_to) const
 {
-       if (_done) {
+       if (done()) {
                return;
        }
 
@@ -325,7 +325,7 @@ void
 Piece::pass ()
 {
        LOG_DEBUG_PLAYER ("Calling pass() on %1", _content->path(0));
-       _done = _decoder->pass();
+       _decoder->pass();
 }
 
 
@@ -356,14 +356,9 @@ Piece::seek (DCPTime time, bool accurate)
                   been trimmed to a point between keyframes, or something).
                   */
                _decoder->seek (dcp_to_content_time(position()), true);
-               _done = false;
        } else if (position() <= time && time < end()) {
                /* During; seek to position */
                _decoder->seek (dcp_to_content_time(time), accurate);
-               _done = false;
-       } else {
-               /* After; this piece is done */
-               _done = true;
        }
 }
 
@@ -371,16 +366,10 @@ Piece::seek (DCPTime time, bool accurate)
 optional<dcpomatic::DCPTime>
 Piece::decoder_before(optional<dcpomatic::DCPTime> time)
 {
-       if (_done) {
-               return {};
-       }
-
        auto t = content_time_to_dcp(_content, std::max(_decoder->position(), _content->trim_start()));
        DCPOMATIC_ASSERT (t);
 
-       if (*t > end()) {
-               _done = true;
-       } else {
+       if (*t < end()) {
                /* Given two choices at the same time, pick the one with texts so we see it before
                   the video.
                   */
@@ -392,6 +381,7 @@ Piece::decoder_before(optional<dcpomatic::DCPTime> time)
        return {};
 }
 
+
 vector<dcpomatic::FontData>
 Piece::fonts () const
 {
@@ -424,3 +414,13 @@ Piece::flush ()
                }
        }
 }
+
+
+bool
+Piece::done () const
+{
+       auto film = _film.lock();
+       DCPOMATIC_ASSERT (film);
+       return content_time_to_dcp(_content, std::max(_decoder->position(), _content->trim_start())) > _content->end(film);
+}
+
index 2586bb1d053ae0b8a361609a3f3f510f9b3f18e3..37336afcbeb34c0c8da6ec99ccd5f7d168f95771 100644 (file)
@@ -107,13 +107,13 @@ private:
        void atmos (std::shared_ptr<const dcp::AtmosFrame> data, Frame frame, AtmosMetadata metadata);
 
        void flush ();
+       bool done () const;
 
        std::weak_ptr<const Film> _film;
        std::shared_ptr<Content> _content;
        std::shared_ptr<Decoder> _decoder;
        FrameRateChange _frc;
        bool _fast = false;
-       bool _done = false;
        boost::optional<dcpomatic::DCPTimePeriod> _ignore_video;
        std::map<AudioStreamPtr, dcpomatic::DCPTime> _stream_last_push_end;