From: Carl Hetherington Date: Sun, 20 Oct 2019 21:24:15 +0000 (+0200) Subject: Add FilmViewer::time_until_next_frame. X-Git-Tag: v2.15.40^2~38 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=0a3f387f5d39da2ca38ec90a9593c1b598040dd7 Add FilmViewer::time_until_next_frame. --- diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 8b90cd9c9..373e6d717 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -633,3 +633,11 @@ FilmViewer::set_pad_black (bool p) { _pad_black = p; } + +/* XXX_b: comment */ +int +FilmViewer::time_until_next_frame () const +{ + DCPTime const next = position() + one_video_frame(); + return max ((next.seconds() - time().seconds()) * 1000, 1.0); +} diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 51419a54d..55356f188 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -119,7 +119,7 @@ public: return _gets; } - /* Some accessors that VideoView classes need */ + /* Some accessors and utility methods that VideoView classes need */ dcp::Size out_size () const { return _out_size; } @@ -138,6 +138,7 @@ public: boost::shared_ptr butler () const { return _butler; } + int time_until_next_frame () const; boost::signals2::signal)> ImageChanged; boost::signals2::signal PositionChanged; diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index f0c63d15a..c195bbc35 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -159,7 +159,7 @@ SimpleVideoView::timer () } LOG_DEBUG_PLAYER("%1 -> %2; delay %3", next.seconds(), _viewer->time().seconds(), max((next.seconds() - _viewer->time().seconds()) * 1000, 1.0)); - _timer.Start (max ((next.seconds() - _viewer->time().seconds()) * 1000, 1.0), wxTIMER_ONE_SHOT); + _timer.Start (_viewer->time_until_next_frame()), wxTIMER_ONE_SHOT); if (_viewer->butler()) { _viewer->butler()->rethrow ();