summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-02-15 02:50:03 +0100
committerCarl Hetherington <cth@carlh.net>2021-02-15 10:56:14 +0100
commit34119b89c286fc486e9035007066e01462afb8c3 (patch)
tree94bcd28cca5b4a0d74649eaec650985210818875
parente48d176b029a365fb879444c4efe41cfbf075fa7 (diff)
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).
-rw-r--r--src/lib/butler.cc28
1 files changed, 15 insertions, 13 deletions
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<PlayerVideo>(), 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<PlayerVideo>(), DCPTime());
}
- pair<shared_ptr<PlayerVideo>, DCPTime> const r = _video.get ();
+ auto const r = _video.get ();
_summon.notify_all ();
return r;
}