diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-10-20 22:13:46 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-01-08 21:56:47 +0100 |
| commit | c76b1fd7fe41a7e371ae1fe1dad21c87a19839f1 (patch) | |
| tree | a487e093d93895fafb529edd6c4ae0e6e8030c3e /src | |
| parent | dde431cafbb20ed3356ad5592be56af1d4458f46 (diff) | |
Move ::timer into SimpleVideoView.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/film_viewer.cc | 27 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 6 | ||||
| -rw-r--r-- | src/wx/simple_video_view.cc | 28 | ||||
| -rw-r--r-- | src/wx/simple_video_view.h | 2 | ||||
| -rw-r--r-- | src/wx/video_view.h | 3 |
5 files changed, 38 insertions, 28 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 509cc9426..9dbb0091a 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -108,7 +108,6 @@ FilmViewer::FilmViewer (wxWindow* p) } _video_view->Sized.connect (boost::bind(&FilmViewer::video_view_sized, this)); - _timer.Bind (wxEVT_TIMER, boost::bind(&FilmViewer::timer, this)); set_film (shared_ptr<Film> ()); @@ -336,30 +335,6 @@ FilmViewer::display_player_video () } void -FilmViewer::timer () -{ - if (!_film || !_playing || _suspended) { - return; - } - - get (false); - DCPTime const next = _video_position + one_video_frame(); - - if (next >= _film->length()) { - stop (); - Finished (); - return; - } - - LOG_DEBUG_PLAYER("%1 -> %2; delay %3", next.seconds(), time().seconds(), max((next.seconds() - time().seconds()) * 1000, 1.0)); - _timer.Start (max ((next.seconds() - time().seconds()) * 1000, 1.0), wxTIMER_ONE_SHOT); - - if (_butler) { - _butler->rethrow (); - } -} - -void FilmViewer::set_outline_content (bool o) { _outline_content = o; @@ -454,7 +429,7 @@ FilmViewer::start () _playing = true; _dropped = 0; - timer (); + _video_view->timer (); Started (position()); } diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 1f20c3321..d64eef4a9 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -149,8 +149,11 @@ public: boost::signals2::signal<bool ()> PlaybackPermitted; private: + + /* XXX_b: to remove */ + friend class SimpleVideoView; + void video_view_sized (); - void timer (); void calculate_sizes (); void player_change (ChangeType type, int, bool); bool get (bool lazy); @@ -172,7 +175,6 @@ private: boost::shared_ptr<Player> _player; VideoView* _video_view; - wxTimer _timer; bool _coalesce_player_changes; std::list<int> _pending_player_changes; diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index 66af8f19f..baf566aee 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -22,6 +22,8 @@ #include "film_viewer.h" #include "wx_util.h" #include "lib/image.h" +#include "lib/dcpomatic_log.h" +#include "lib/butler.h" #include <dcp/util.h> #include <wx/wx.h> #include <boost/bind.hpp> @@ -45,6 +47,8 @@ SimpleVideoView::SimpleVideoView (FilmViewer* viewer, wxWindow* parent) _panel->Bind (wxEVT_PAINT, boost::bind (&SimpleVideoView::paint, this)); _panel->Bind (wxEVT_SIZE, boost::bind(boost::ref(Sized))); + + _timer.Bind (wxEVT_TIMER, boost::bind(&SimpleVideoView::timer, this)); } void @@ -135,3 +139,27 @@ SimpleVideoView::update () _panel->Refresh (); _panel->Update (); } + +void +SimpleVideoView::timer () +{ + if (!_viewer->_film || !_viewer->_playing) { + return; + } + + _viewer->get (false); + DCPTime const next = _viewer->_video_position + _viewer->one_video_frame(); + + if (next >= _viewer->_film->length()) { + _viewer->stop (); + _viewer->Finished (); + return; + } + + 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); + + if (_viewer->_butler) { + _viewer->_butler->rethrow (); + } +} diff --git a/src/wx/simple_video_view.h b/src/wx/simple_video_view.h index 686a1a1f3..82c77a4ef 100644 --- a/src/wx/simple_video_view.h +++ b/src/wx/simple_video_view.h @@ -40,7 +40,9 @@ public: private: void paint (); + void timer (); wxPanel* _panel; boost::shared_ptr<const Image> _image; + wxTimer _timer; }; diff --git a/src/wx/video_view.h b/src/wx/video_view.h index 892ffab12..8b86b2ba1 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -46,6 +46,9 @@ public: boost::signals2::signal<void()> Sized; + /* XXX_b: to remove */ + virtual void timer () {} + protected: FilmViewer* _viewer; |
