Move FilmViewer::get() into SimpleVideoView.
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Oct 2019 20:49:07 +0000 (22:49 +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 be555ad..0b6fcd7 100644 (file)
@@ -140,7 +140,7 @@ FilmViewer::idle_handler ()
                return;
        }
 
-       if (get(true)) {
+       if (_video_view->get(true)) {
                _idle_get = false;
        } else {
                /* get() could not complete quickly so we'll try again later */
@@ -236,49 +236,6 @@ FilmViewer::refresh_view ()
        _state_timer.unset ();
 }
 
-/** Try to get a frame from the butler and display it.
- *  @param lazy true to return false quickly if no video is available quickly (i.e. we are waiting for the butler).
- *  false to ask the butler to block until it has video (unless it is suspended).
- *  @return true on success, false if we did nothing because it would have taken too long.
- */
-bool
-FilmViewer::get (bool lazy)
-{
-       DCPOMATIC_ASSERT (_butler);
-       ++_gets;
-
-       do {
-               Butler::Error e;
-               _player_video = _butler->get_video (!lazy, &e);
-               if (!_player_video.first && e == Butler::AGAIN) {
-                       if (lazy) {
-                               /* No video available; return saying we failed */
-                               return false;
-                       } else {
-                               /* Player was suspended; come back later */
-                               signal_manager->when_idle (boost::bind(&FilmViewer::get, this, false));
-                               return false;
-                       }
-               }
-       } while (
-               _player_video.first &&
-               _film->three_d() &&
-               _eyes != _player_video.first->eyes() &&
-               _player_video.first->eyes() != EYES_BOTH
-               );
-
-       try {
-               _butler->rethrow ();
-       } catch (DecodeError& e) {
-               error_dialog (_video_view->get(), e.what());
-       }
-
-       display_player_video ();
-       PositionChanged ();
-
-       return true;
-}
-
 void
 FilmViewer::display_player_video ()
 {
index d0041bd..077d8a6 100644 (file)
@@ -153,7 +153,6 @@ private:
        void video_view_sized ();
        void calculate_sizes ();
        void player_change (ChangeType type, int, bool);
-       bool get (bool lazy);
        void idle_handler ();
        void request_idle_get ();
        void display_player_video ();
index 37daecd..7d20800 100644 (file)
@@ -147,7 +147,7 @@ SimpleVideoView::timer ()
                return;
        }
 
-       _viewer->get (false);
+       get (false);
        DCPTime const next = _viewer->position() + _viewer->one_video_frame();
 
        if (next >= _viewer->film()->length()) {
@@ -169,3 +169,46 @@ SimpleVideoView::start ()
 {
        timer ();
 }
+
+/** Try to get a frame from the butler and display it.
+ *  @param lazy true to return false quickly if no video is available quickly (i.e. we are waiting for the butler).
+ *  false to ask the butler to block until it has video (unless it is suspended).
+ *  @return true on success, false if we did nothing because it would have taken too long.
+ */
+bool
+SimpleVideoView::get (bool lazy)
+{
+       DCPOMATIC_ASSERT (_viewer->_butler);
+       _viewer->_gets++;
+
+       do {
+               Butler::Error e;
+               _viewer->_player_video = _viewer->_butler->get_video (!lazy, &e);
+               if (!_viewer->_player_video.first && e == Butler::AGAIN) {
+                       if (lazy) {
+                               /* No video available; return saying we failed */
+                               return false;
+                       } else {
+                               /* Player was suspended; come back later */
+                               signal_manager->when_idle (boost::bind(&SimpleVideoView::get, this, false));
+                               return false;
+                       }
+               }
+       } while (
+               _viewer->_player_video.first &&
+               _viewer->film()->three_d() &&
+               _viewer->_eyes != _viewer->_player_video.first->eyes() &&
+               _viewer->_player_video.first->eyes() != EYES_BOTH
+               );
+
+       try {
+               _viewer->_butler->rethrow ();
+       } catch (DecodeError& e) {
+               error_dialog (get(), e.what());
+       }
+
+       _viewer->display_player_video ();
+       _viewer->PositionChanged ();
+
+       return true;
+}
index 798356c..d271416 100644 (file)
@@ -43,6 +43,7 @@ public:
 private:
        void paint ();
        void timer ();
+       bool get (bool lazy);
 
        wxPanel* _panel;
        boost::shared_ptr<const Image> _image;
index dda1805..80d6a50 100644 (file)
@@ -49,6 +49,11 @@ public:
 
        boost::signals2::signal<void()> Sized;
 
+       /* XXX_b: to remove */
+       virtual bool get (bool) {
+               return true;
+       }
+
 protected:
        FilmViewer* _viewer;