Hold lock for the whole of Butler::video(). Fixes jumpy nudge-seek
authorCarl Hetherington <cth@carlh.net>
Sun, 18 Feb 2018 01:26:03 +0000 (01:26 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 18 Feb 2018 01:28:39 +0000 (01:28 +0000)
when playing DCPs.

Before, the lock was only held to check _pending_seek_position.
With that arrangement, this sequence was possible:
1. video arrives, check _pending_seek_position, decide it's ok, release lock
2. Butler::seek called, sets _pending_seek_position, clears _video
3. video that arrived in #1 is put into _video by ::video()
4. that video is given to an awaiting get_video() call.
This clearly subverts the attempts not to accept new video data while
a seek is pending.

src/lib/butler.cc

index 81ddb1d44629fcb8b5706e5650978b491275de54..f7c3c8fd99494e6760b9250c300db6b37800dbde 100644 (file)
@@ -214,12 +214,10 @@ Butler::prepare (weak_ptr<PlayerVideo> weak_video) const
 void
 Butler::video (shared_ptr<PlayerVideo> video, DCPTime time)
 {
-       {
-               boost::mutex::scoped_lock lm (_mutex);
-               if (_pending_seek_position) {
-                       /* Don't store any video while a seek is pending */
-                       return;
-               }
+       boost::mutex::scoped_lock lm (_mutex);
+       if (_pending_seek_position) {
+               /* Don't store any video while a seek is pending */
+               return;
        }
 
        _prepare_service.post (bind (&Butler::prepare, this, weak_ptr<PlayerVideo>(video)));