Allow nested butler suspensions.
authorCarl Hetherington <cth@carlh.net>
Mon, 20 Aug 2018 11:01:34 +0000 (12:01 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 20 Aug 2018 11:01:34 +0000 (12:01 +0100)
src/lib/butler.cc
src/lib/butler.h

index 3a75e67d75ae56f4a14207e5d4d093360d153e4d..07cb7b22bf7a839edb75a960561095bcc88bfb24 100644 (file)
@@ -54,7 +54,7 @@ Butler::Butler (shared_ptr<Player> player, shared_ptr<Log> log, AudioMapping aud
        , _log (log)
        , _prepare_work (new boost::asio::io_service::work (_prepare_service))
        , _pending_seek_accurate (false)
-       , _suspended (false)
+       , _suspended (0)
        , _finished (false)
        , _died (false)
        , _stop_thread (false)
@@ -315,9 +315,9 @@ Butler::player_change (ChangeType type, bool frequent)
        boost::mutex::scoped_lock lm (_mutex);
 
        if (type == CHANGE_TYPE_PENDING) {
-               _suspended = true;
+               ++_suspended;
        } else if (type == CHANGE_TYPE_DONE) {
-
+               --_suspended;
                if (_died || _pending_seek_position || frequent) {
                        return;
                }
@@ -334,8 +334,9 @@ Butler::player_change (ChangeType type, bool frequent)
                }
 
                seek_unlocked (seek_to, true);
-               _suspended = false;
                _awaiting = seek_to;
+       } else if (type == CHANGE_TYPE_CANCELLED) {
+               --_suspended;
        }
 }
 
index 513176821e8f455c46f312d5458534e0809b2e5e..b10c93e7984c5a581615d73ac6ab959a86074c1c 100644 (file)
@@ -83,7 +83,7 @@ private:
        boost::condition _arrived;
        boost::optional<DCPTime> _pending_seek_position;
        bool _pending_seek_accurate;
-       bool _suspended;
+       int _suspended;
        bool _finished;
        bool _died;
        bool _stop_thread;