Small refactoring.
authorCarl Hetherington <cth@carlh.net>
Sun, 7 May 2017 23:32:55 +0000 (00:32 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 7 May 2017 23:35:55 +0000 (00:35 +0100)
src/lib/player.cc
src/lib/player.h

index 1f5639f68bc5d1be00767faf805d8c5bc5981e08..081174acc301acdb90d518b148c7b8747d72bc98 100644 (file)
@@ -650,16 +650,7 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
                        )
                );
 
-       optional<PositionImage> subtitles = subtitles_for_frame (time);
-       if (subtitles) {
-               _last_video->set_subtitle (subtitles.get ());
-       }
-
-       Video (_last_video, time);
-
-       _last_video_time = time + one_video_frame ();
-
-       _active_subtitles.clear_before (time);
+       emit_video (_last_video, time);
 }
 
 void
@@ -950,20 +941,26 @@ Player::fill_video (DCPTimePeriod period)
        BOOST_FOREACH (DCPTimePeriod i, subtract(period, _no_video)) {
                for (DCPTime j = i.from; j < i.to; j += one_video_frame()) {
                        if (_playlist->video_content_at(j) && _last_video) {
-                               Video (shared_ptr<PlayerVideo> (new PlayerVideo (*_last_video)), j);
+                               emit_video (shared_ptr<PlayerVideo> (new PlayerVideo (*_last_video)), j);
                        } else {
-                               shared_ptr<PlayerVideo> black = black_player_video_frame ();
-                               optional<PositionImage> subtitles = subtitles_for_frame (j);
-                               if (subtitles) {
-                                       black->set_subtitle (subtitles.get ());
-                               }
-                               Video (black, j);
+                               emit_video (black_player_video_frame(), j);
                        }
-                       _last_video_time = j;
                }
        }
 }
 
+void
+Player::emit_video (shared_ptr<PlayerVideo> pv, DCPTime time)
+{
+       optional<PositionImage> subtitles = subtitles_for_frame (time);
+       if (subtitles) {
+               pv->set_subtitle (subtitles.get ());
+       }
+       Video (pv, time);
+       _last_video_time = time + one_video_frame();
+       _active_subtitles.clear_before (time);
+}
+
 void
 Player::fill_audio (DCPTimePeriod period)
 {
index 760b54a605f3e1eee868875749ddf8d2d581c187..ea792d4dab1c8313d394d33da5e9d97e08882243 100644 (file)
@@ -118,6 +118,7 @@ private:
                boost::shared_ptr<const AudioBuffers> audio, DCPTime time, DCPTime discard_to
                ) const;
        boost::optional<PositionImage> subtitles_for_frame (DCPTime time) const;
+       void emit_video (boost::shared_ptr<PlayerVideo> pv, DCPTime time);
 
        boost::shared_ptr<const Film> _film;
        boost::shared_ptr<const Playlist> _playlist;