From a57717d54c34096d80a467ad78e9fdcecca70b2c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 4 Sep 2018 12:50:25 +0100 Subject: Allow the butler to say "try again later" when get_video() is called while it's suspended. Then make the GUI follow that suggestion. Should --- src/lib/butler.cc | 14 ++++++++++++-- src/lib/butler.h | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/butler.cc b/src/lib/butler.cc index a127ee9bd..3e408c4d5 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -190,17 +190,27 @@ try } pair, 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(), DCPTime()); + } + /* Wait for data if we have none */ while (_video.empty() && !_finished && !_died) { _arrived.wait (lm); } if (_video.empty()) { - return make_pair (shared_ptr(), DCPTime()); + if (e) { + *e = NONE; + } + return make_pair(shared_ptr(), DCPTime()); } pair, DCPTime> const r = _video.get (); diff --git a/src/lib/butler.h b/src/lib/butler.h index 4322c401d..fb133d108 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -41,7 +41,13 @@ public: ~Butler (); void seek (DCPTime position, bool accurate); - std::pair, DCPTime> get_video (); + + enum Error { + NONE, + AGAIN + }; + + std::pair, DCPTime> get_video (Error* e = 0); boost::optional get_audio (float* out, Frame frames); boost::optional get_closed_caption (); -- cgit v1.2.3