Move ::timer into SimpleVideoView.
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Oct 2019 20:13:46 +0000 (22:13 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 8 Jan 2020 20:56:47 +0000 (21:56 +0100)
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/simple_video_view.cc
src/wx/simple_video_view.h
src/wx/video_view.h

index 509cc9426dd279ed14e960f6b12a8a4f5f2263dc..9dbb0091a348270bed8a211d92818f7d11cdf71d 100644 (file)
@@ -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> ());
 
@@ -335,30 +334,6 @@ FilmViewer::display_player_video ()
        _closed_captions_dialog->update (time());
 }
 
-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)
 {
@@ -454,7 +429,7 @@ FilmViewer::start ()
 
        _playing = true;
        _dropped = 0;
-       timer ();
+       _video_view->timer ();
        Started (position());
 }
 
index 1f20c3321f0ccc999f285c01692edd000010e872..d64eef4a9826d6eeb23702db65523153136126bf 100644 (file)
@@ -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;
 
index 66af8f19f58b75b3b30666211977a7f000ac8f36..baf566aee96e4308cf64df166f12f5e121ecbb6d 100644 (file)
@@ -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 ();
+       }
+}
index 686a1a1f3cc83c686569a617dafd605e677aac39..82c77a4efeb91ad2f9d5def42950299a877448b7 100644 (file)
@@ -40,7 +40,9 @@ public:
 
 private:
        void paint ();
+       void timer ();
 
        wxPanel* _panel;
        boost::shared_ptr<const Image> _image;
+       wxTimer _timer;
 };
index 892ffab125d08560fed8542937d36a364322f77f..8b86b2ba188da5d50ba4753a080e130bec9c073b 100644 (file)
@@ -46,6 +46,9 @@ public:
 
        boost::signals2::signal<void()> Sized;
 
+       /* XXX_b: to remove */
+       virtual void timer () {}
+
 protected:
        FilmViewer* _viewer;