summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-08-22 22:00:11 +0100
committerCarl Hetherington <cth@carlh.net>2018-08-22 22:00:11 +0100
commit43b8c87f18793d57a9752f360614a5640dad9810 (patch)
tree53609e046bc273c87ee68719e160db7c55c988be /src/lib
parent2571104b6a208fa00b2c98d50f97849c3e7fa6c9 (diff)
Await video in get_video() if we are suspended.
Fix player_change to summon the butler if _suspended is changed, and ensure that the butler's Player::Change handler is the first to be called so that suspension is sorted out before any other Player::Change handlers might call get_video(). This is to prevent the sequence 1. player change-pending emitted 2. hence butler suspended -> 1 3. player change-done emitted 4. first handler is something which calls get_video() 5. get_video() awaits video which will never arrive because the butler is suspended. Here there is a pending change-done signal to butler. Ensuring this arrives before the handler which calls get_video() sorts it out.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/butler.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc
index 07cb7b22b..de9ed4ed0 100644
--- a/src/lib/butler.cc
+++ b/src/lib/butler.cc
@@ -65,7 +65,10 @@ Butler::Butler (shared_ptr<Player> player, shared_ptr<Log> log, AudioMapping aud
_player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2));
_player_audio_connection = _player->Audio.connect (bind (&Butler::audio, this, _1, _2));
_player_text_connection = _player->Text.connect (bind (&Butler::text, this, _1, _2, _3));
- _player_change_connection = _player->Change.connect (bind (&Butler::player_change, this, _1, _3));
+ /* The butler must here about things first, otherwise it might not sort out suspensions in time for
+ get_video() to be called in response to this signal.
+ */
+ _player_change_connection = _player->Change.connect (bind (&Butler::player_change, this, _1, _3), boost::signals2::at_front);
_thread = new boost::thread (bind (&Butler::thread, this));
#ifdef DCPOMATIC_LINUX
pthread_setname_np (_thread->native_handle(), "butler");
@@ -192,7 +195,7 @@ Butler::get_video ()
boost::mutex::scoped_lock lm (_mutex);
/* Wait for data if we have none */
- while (_video.empty() && !_finished && !_died && !_suspended) {
+ while (_video.empty() && !_finished && !_died) {
_arrived.wait (lm);
}
@@ -319,6 +322,8 @@ Butler::player_change (ChangeType type, bool frequent)
} else if (type == CHANGE_TYPE_DONE) {
--_suspended;
if (_died || _pending_seek_position || frequent) {
+ lm.unlock ();
+ _summon.notify_all ();
return;
}
@@ -338,6 +343,9 @@ Butler::player_change (ChangeType type, bool frequent)
} else if (type == CHANGE_TYPE_CANCELLED) {
--_suspended;
}
+
+ lm.unlock ();
+ _summon.notify_all ();
}
void