diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-07-23 22:55:15 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-01-25 01:47:00 +0100 |
| commit | af0edaf7dcd36c367cb585c98e8413c5347a7386 (patch) | |
| tree | 8ad8ad0d1e46523d2f3c3550994024cb3720013c | |
| parent | 4162285358cb4611e9faa7de576d57b47dbf2ec4 (diff) | |
Cache film length for Player::pass.
| -rw-r--r-- | src/lib/player.cc | 8 | ||||
| -rw-r--r-- | src/lib/player.h | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index 79db7cc2c..657c1a8b4 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -243,6 +243,9 @@ Player::setup_pieces_unlocked () _last_video_time = DCPTime (); _last_video_eyes = EYES_BOTH; _last_audio_time = DCPTime (); + + /* Cached value to save recalculating it on every ::pass */ + _film_length = _film->length (); } void @@ -564,13 +567,14 @@ bool Player::pass () { boost::mutex::scoped_lock lm (_mutex); + DCPOMATIC_ASSERT (_film_length); if (_suspended) { /* We can't pass in this state */ return false; } - if (_playlist->length(_film) == DCPTime()) { + if (*_film_length == DCPTime()) { /* Special case of an empty Film; just give one black frame */ emit_video (black_player_video_frame(EYES_BOTH), DCPTime()); return true; @@ -677,7 +681,7 @@ Player::pass () /* Work out the time before which the audio is definitely all here. This is the earliest last_push_end of one of our streams, or the position of the _silent. */ - DCPTime pull_to = _film->length (); + DCPTime pull_to = *_film_length; for (map<AudioStreamPtr, StreamState>::const_iterator i = _stream_states.begin(); i != _stream_states.end(); ++i) { if (!i->second.piece->done && i->second.last_push_end < pull_to) { pull_to = i->second.last_push_end; diff --git a/src/lib/player.h b/src/lib/player.h index e99c345bb..2fd7c8668 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -206,6 +206,9 @@ private: ActiveText _active_texts[TEXT_COUNT]; boost::shared_ptr<AudioProcessor> _audio_processor; + /* Cached stuff */ + boost::optional<dcpomatic::DCPTime> _film_length; + boost::signals2::scoped_connection _film_changed_connection; boost::signals2::scoped_connection _playlist_change_connection; boost::signals2::scoped_connection _playlist_content_change_connection; |
