summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-04-26 11:01:44 +0100
committerCarl Hetherington <cth@carlh.net>2017-04-26 11:01:44 +0100
commitd0ecbc635fa3931fe6a588c3ffb038d1f3e1b11c (patch)
tree08bf7ebd62667e011c26f6d0115da3fd3a81b43b /src/lib
parent3a7adf45e7820902e446c56114e25075e0a42a1f (diff)
Fix video flickering when seeking near the end of the film.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/butler.cc12
-rw-r--r--src/lib/butler.h4
2 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc
index b9aa0a5db..89095613d 100644
--- a/src/lib/butler.cc
+++ b/src/lib/butler.cc
@@ -42,9 +42,9 @@ Butler::Butler (weak_ptr<const Film> film, shared_ptr<Player> player, AudioMappi
, _pending_seek_accurate (false)
, _finished (false)
, _died (false)
+ , _stop_thread (false)
, _audio_mapping (audio_mapping)
, _audio_channels (audio_channels)
- , _stop_thread (false)
, _disable_audio (false)
{
_player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2));
@@ -55,7 +55,11 @@ Butler::Butler (weak_ptr<const Film> film, shared_ptr<Player> player, AudioMappi
Butler::~Butler ()
{
- _stop_thread = true;
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _stop_thread = true;
+ }
+
_thread->interrupt ();
try {
_thread->join ();
@@ -65,6 +69,7 @@ Butler::~Butler ()
delete _thread;
}
+/** Caller must hold a lock on _mutex */
bool
Butler::should_run () const
{
@@ -97,7 +102,8 @@ try
lm.unlock ();
bool const r = _player->pass ();
lm.lock ();
- if (r) {
+ /* We must check _pending_seek_position again here as it may have been set while lm was unlocked */
+ if (r && !_pending_seek_position) {
_finished = true;
_arrived.notify_all ();
break;
diff --git a/src/lib/butler.h b/src/lib/butler.h
index 2cb49c1a6..c2c5d8ca5 100644
--- a/src/lib/butler.h
+++ b/src/lib/butler.h
@@ -58,19 +58,19 @@ private:
VideoRingBuffers _video;
AudioRingBuffers _audio;
+ /** mutex to protect _pending_seek_position, _pending_seek_acurate, _finished, _died, _stop_thread */
boost::mutex _mutex;
boost::condition _summon;
boost::condition _arrived;
boost::optional<DCPTime> _pending_seek_position;
bool _pending_seek_accurate;
-
bool _finished;
bool _died;
+ bool _stop_thread;
AudioMapping _audio_mapping;
int _audio_channels;
- bool _stop_thread;
bool _disable_audio;
boost::signals2::scoped_connection _player_video_connection;