Allow the butler to say "try again later" when get_video() is called
authorCarl Hetherington <cth@carlh.net>
Tue, 4 Sep 2018 11:50:25 +0000 (12:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 4 Sep 2018 11:50:25 +0000 (12:50 +0100)
while it's suspended.  Then make the GUI follow that suggestion.
Should

src/lib/butler.cc
src/lib/butler.h
src/wx/film_viewer.cc

index a127ee9bdeeff61428e19663d7a2c36f875f5288..3e408c4d52e852e19e853a83087e0f477c9b9c7b 100644 (file)
@@ -190,17 +190,27 @@ try
 }
 
 pair<shared_ptr<PlayerVideo>, DCPTime>
-Butler::get_video ()
+Butler::get_video (Error* e)
 {
        boost::mutex::scoped_lock lm (_mutex);
 
+       if (_suspended) {
+               if (e) {
+                       *e = AGAIN;
+               }
+               return make_pair(shared_ptr<PlayerVideo>(), DCPTime());
+       }
+
        /* Wait for data if we have none */
        while (_video.empty() && !_finished && !_died) {
                _arrived.wait (lm);
        }
 
        if (_video.empty()) {
-               return make_pair (shared_ptr<PlayerVideo>(), DCPTime());
+               if (e) {
+                       *e = NONE;
+               }
+               return make_pair(shared_ptr<PlayerVideo>(), DCPTime());
        }
 
        pair<shared_ptr<PlayerVideo>, DCPTime> const r = _video.get ();
index 4322c401dc1b62824470c8a0d7df0aeaf35a3ecf..fb133d10809413298364faba4e02a8d62c42c5b1 100644 (file)
@@ -41,7 +41,13 @@ public:
        ~Butler ();
 
        void seek (DCPTime position, bool accurate);
-       std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video ();
+
+       enum Error {
+               NONE,
+               AGAIN
+       };
+
+       std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video (Error* e = 0);
        boost::optional<DCPTime> get_audio (float* out, Frame frames);
        boost::optional<TextRingBuffers::Data> get_closed_caption ();
 
index 76e269975fb0eea467589e0a4a9ed775c1983c73..d954e1818a59a7b89cb5b20b1c133267661595c3 100644 (file)
@@ -294,7 +294,12 @@ FilmViewer::get ()
        DCPOMATIC_ASSERT (_butler);
 
        do {
-               _player_video = _butler->get_video ();
+               Butler::Error e;
+               _player_video = _butler->get_video (&e);
+               if (!_player_video.first && e == Butler::AGAIN) {
+                       signal_manager->when_idle (boost::bind(&FilmViewer::get, this));
+                       return;
+               }
        } while (
                _player_video.first &&
                _film->three_d() &&