Move some stuff for position checking.
authorCarl Hetherington <cth@carlh.net>
Tue, 23 Jun 2020 21:01:10 +0000 (23:01 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Dec 2020 15:38:52 +0000 (16:38 +0100)
src/lib/piece.h
src/lib/player.cc

index 31fbfc2568354f314a146dda4c2ccea5aeade3b7..f150dfe53d0a3b5dba098ab0b7056cb75f947f10 100644 (file)
@@ -22,6 +22,7 @@
 #define DCPOMATIC_PIECE_H
 
 #include "audio_stream.h"
+#include "dcpomatic_font.h"
 #include "dcpomatic_time.h"
 #include "frame_rate_change.h"
 #include "types.h"
@@ -36,6 +37,8 @@ public:
 
        void update_pull_to (dcpomatic::DCPTime& pull_to) const;
        void set_last_push_end (AudioStreamPtr stream, dcpomatic::DCPTime last_push_end);
+       boost::optional<dcpomatic::DCPTime> position (boost::shared_ptr<const Film> film);
+       bool has_text () const;
 
        dcpomatic::DCPTime position () const;
        dcpomatic::DCPTime end (boost::shared_ptr<const Film> film) const;
index 9445d63b8cb0ce678595b705dac57fe4ca3ed981..a0bd257be8bd16dacd963509e8b82fc1c910f009 100644 (file)
@@ -557,21 +557,14 @@ Player::pass ()
        optional<DCPTime> earliest_time;
 
        BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
-               if (i->done) {
-                       continue;
-               }
-
-               DCPTime const t = content_time_to_dcp (i, max(i->decoder->position(), i->content->trim_start()));
-               if (t > i->end(_film)) {
-                       i->done = true;
-               } else {
-
-                       /* Given two choices at the same time, pick the one with texts so we see it before
-                          the video.
-                       */
-                       if (!earliest_time || t < *earliest_time || (t == *earliest_time && !i->decoder->text.empty())) {
-                               earliest_time = t;
+               optional<DCPTime> t = i->position ();
+               /* Given two choices at the same time, pick the one with texts so we see it before
+                  the video.
+                  */
+               if (t) {
+                       if (!earliest_time || *t < *earliest_time || (*t == *earliest_time && i->has_text())) {
                                earliest_content = i;
+                               earliest_time = *t;
                        }
                }
        }