From 0a3f387f5d39da2ca38ec90a9593c1b598040dd7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 20 Oct 2019 23:24:15 +0200 Subject: [PATCH] Add FilmViewer::time_until_next_frame. --- src/wx/film_viewer.cc | 8 ++++++++ src/wx/film_viewer.h | 3 ++- src/wx/simple_video_view.cc | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) 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 (); -- 2.30.2