From 34119b89c286fc486e9035007066e01462afb8c3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 15 Feb 2021 02:50:03 +0100 Subject: Don't keep returning AGAIN from the butler when it is already dead/finished. This causes, for example, player UI hangs when trying to play something unplayable (e.g. a DCP with no KDM). --- src/lib/butler.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 56acbd8a0..d4da787dd 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -237,10 +237,21 @@ Butler::get_video (bool blocking, Error* e) { boost::mutex::scoped_lock lm (_mutex); - if (_suspended || (_video.empty() && !blocking)) { + auto setup_error = [this](Error* e, Error::Code fallback) { if (e) { - e->code = Error::AGAIN; + if (_died) { + e->code = Error::DIED; + e->message = _died_message; + } else if (_finished) { + e->code = Error::FINISHED; + } else { + e->code = fallback; + } } + }; + + if (_video.empty() && (_finished || _died || (_suspended && !blocking))) { + setup_error (e, Error::AGAIN); return make_pair(shared_ptr(), DCPTime()); } @@ -250,20 +261,11 @@ Butler::get_video (bool blocking, Error* e) } if (_video.empty()) { - if (e) { - if (_died) { - e->code = Error::DIED; - e->message = _died_message; - } else if (_finished) { - e->code = Error::FINISHED; - } else { - e->code = Error::NONE; - } - } + setup_error (e, Error::NONE); return make_pair(shared_ptr(), DCPTime()); } - pair, DCPTime> const r = _video.get (); + auto const r = _video.get (); _summon.notify_all (); return r; } -- cgit v1.2.3