From d5085584d82c021e924cec6ce00e682a8e63d800 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 16 Jul 2013 11:49:08 +0100 Subject: Prevent viewer updates on timeline drag (#175). --- src/lib/content.cc | 7 ++++++- src/lib/content.h | 8 +++++++- src/lib/player.cc | 18 +++++++++--------- src/lib/player.h | 6 ++++-- src/lib/playlist.cc | 8 ++++---- src/lib/playlist.h | 5 +++-- 6 files changed, 33 insertions(+), 19 deletions(-) (limited to 'src/lib') diff --git a/src/lib/content.cc b/src/lib/content.cc index 6a33e9f7e..49c579fb6 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -24,6 +24,7 @@ #include "util.h" using std::string; +using std::set; using boost::shared_ptr; using boost::lexical_cast; @@ -33,6 +34,7 @@ int const ContentProperty::LENGTH = 401; Content::Content (shared_ptr f, Time s) : _film (f) , _start (s) + , _change_signals_frequent (false) { } @@ -41,12 +43,14 @@ Content::Content (shared_ptr f, boost::filesystem::path p) : _film (f) , _file (p) , _start (0) + , _change_signals_frequent (false) { } Content::Content (shared_ptr f, shared_ptr node) : _film (f) + , _change_signals_frequent (false) { _file = node->string_child ("File"); _digest = node->string_child ("Digest"); @@ -59,6 +63,7 @@ Content::Content (Content const & o) , _file (o._file) , _digest (o._digest) , _start (o._start) + , _change_signals_frequent (o._change_signals_frequent) { } @@ -83,7 +88,7 @@ Content::examine (shared_ptr) void Content::signal_changed (int p) { - Changed (shared_from_this (), p); + Changed (shared_from_this (), p, _change_signals_frequent); } void diff --git a/src/lib/content.h b/src/lib/content.h index a190a393f..cd8914cba 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -20,6 +20,7 @@ #ifndef DCPOMATIC_CONTENT_H #define DCPOMATIC_CONTENT_H +#include #include #include #include @@ -79,7 +80,11 @@ public: return start() + length(); } - boost::signals2::signal, int)> Changed; + void set_change_signals_frequent (bool f) { + _change_signals_frequent = f; + } + + boost::signals2::signal, int, bool)> Changed; protected: void signal_changed (int); @@ -91,6 +96,7 @@ private: boost::filesystem::path _file; std::string _digest; Time _start; + bool _change_signals_frequent; }; #endif diff --git a/src/lib/player.cc b/src/lib/player.cc index 6ee8c5029..50f401fb7 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -97,7 +97,7 @@ Player::Player (shared_ptr f, shared_ptr p) , _audio_buffers (f->dcp_audio_channels(), 0) { _playlist->Changed.connect (bind (&Player::playlist_changed, this)); - _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2)); + _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3)); _film->Changed.connect (bind (&Player::film_changed, this, _1)); set_video_container_size (_film->container()->size (_film->full_frame ())); } @@ -461,7 +461,7 @@ Player::setup_pieces () } void -Player::content_changed (weak_ptr w, int p) +Player::content_changed (weak_ptr w, int property, bool frequent) { shared_ptr c = w.lock (); if (!c) { @@ -469,16 +469,16 @@ Player::content_changed (weak_ptr w, int p) } if ( - p == ContentProperty::START || p == ContentProperty::LENGTH || - p == VideoContentProperty::VIDEO_CROP || p == VideoContentProperty::VIDEO_RATIO + property == ContentProperty::START || property == ContentProperty::LENGTH || + property == VideoContentProperty::VIDEO_CROP || property == VideoContentProperty::VIDEO_RATIO ) { _have_valid_pieces = false; - Changed (); + Changed (frequent); - } else if (p == SubtitleContentProperty::SUBTITLE_OFFSET || p == SubtitleContentProperty::SUBTITLE_SCALE) { + } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET || property == SubtitleContentProperty::SUBTITLE_SCALE) { update_subtitle (); - Changed (); + Changed (frequent); } } @@ -486,7 +486,7 @@ void Player::playlist_changed () { _have_valid_pieces = false; - Changed (); + Changed (false); } void @@ -541,7 +541,7 @@ Player::film_changed (Film::Property p) */ if (p == Film::SCALER || p == Film::WITH_SUBTITLES || p == Film::CONTAINER) { - Changed (); + Changed (false); } } diff --git a/src/lib/player.h b/src/lib/player.h index 92a358043..2d8eca9b3 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -71,8 +71,10 @@ public: /** Emitted when something has changed such that if we went back and emitted * the last frame again it would look different. This is not emitted after * a seek. + * + * The parameter is true if these signals are currently likely to be frequent. */ - boost::signals2::signal Changed; + boost::signals2::signal Changed; private: friend class PlayerWrapper; @@ -82,7 +84,7 @@ private: void process_subtitle (boost::weak_ptr, boost::shared_ptr, dcpomatic::Rect, Time, Time); void setup_pieces (); void playlist_changed (); - void content_changed (boost::weak_ptr, int); + void content_changed (boost::weak_ptr, int, bool); void do_seek (Time, bool); void flush (); void emit_black (); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 1535ad61f..5aa913bc7 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -70,13 +70,13 @@ Playlist::~Playlist () } void -Playlist::content_changed (weak_ptr c, int p) +Playlist::content_changed (weak_ptr content, int property, bool frequent) { - if (p == ContentProperty::LENGTH) { + if (property == ContentProperty::LENGTH) { maybe_sequence_video (); } - ContentChanged (c, p); + ContentChanged (content, property, frequent); } @@ -285,7 +285,7 @@ Playlist::reconnect () _content_connections.clear (); for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2))); + _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2, _3))); } } diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 805df4d70..0b928fe51 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -89,10 +89,11 @@ public: void maybe_sequence_video (); mutable boost::signals2::signal Changed; - mutable boost::signals2::signal, int)> ContentChanged; + /** Third parameter is true if signals are currently being emitted frequently */ + mutable boost::signals2::signal, int, bool)> ContentChanged; private: - void content_changed (boost::weak_ptr, int); + void content_changed (boost::weak_ptr, int, bool); void reconnect (); ContentList _content; -- cgit v1.2.3