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 be555ad91f556beb19937d4585408af0d6f44e7d..0b6fcd7b353b1fb6cc869c21b6880a1967ad2f76 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 d0041bd957e6394d62acdc1b79f995a7b43006a9..077d8a6a54c17dd146761ce4cccfb98a3a759b38 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 37daecda2be113823ac694c29e5a9845523e6b86..7d2080003fd147b2624e8078740eb18b72857a5a 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 798356cee448e30bfe90189478ff16ae36048509..d271416528390ad39b04377614d53098f3791962 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 dda18058d4e6a4309aa31ffeed1b58ce87d77d95..80d6a50fc454050174de5bad6dcd598548cd85f0 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;