Changes to crop can be handled with a reset_metadata().
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Dec 2020 10:32:36 +0000 (11:32 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Dec 2020 10:32:36 +0000 (11:32 +0100)
While playback is happening we need to do that in the butler's
buffers and in the little delay inside Player.

This removes the seek on every crop change, making it a lot
quicker (#1758).

src/lib/butler.cc
src/lib/butler.h
src/lib/player.cc

index 4ab0092c4d0f819bbc625a3d18f66da4a0ec2c9a..270abd2d6348dc32f6d7009cfde5683c3f4b8c91 100644 (file)
@@ -26,6 +26,7 @@
 #include "cross.h"
 #include "compose.hpp"
 #include "exceptions.h"
+#include "video_content.h"
 #include <boost/weak_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 
@@ -89,7 +90,7 @@ Butler::Butler (
        /* The butler must hear 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), boost::signals2::at_front);
+       _player_change_connection = _player->Change.connect (bind (&Butler::player_change, this, _1, _2), boost::signals2::at_front);
        _thread = boost::thread (bind(&Butler::thread, this));
 #ifdef DCPOMATIC_LINUX
        pthread_setname_np (_thread.native_handle(), "butler");
@@ -381,8 +382,18 @@ Butler::memory_used () const
 }
 
 void
-Butler::player_change (ChangeType type)
+Butler::player_change (ChangeType type, int property)
 {
+       if (property == VideoContentProperty::CROP) {
+               if (type == CHANGE_TYPE_DONE) {
+                       shared_ptr<const Film> film = _film.lock();
+                       if (film) {
+                               _video.reset_metadata (film, _player->video_container_size());
+                       }
+               }
+               return;
+       }
+
        boost::mutex::scoped_lock lm (_mutex);
 
        if (type == CHANGE_TYPE_PENDING) {
index 1fe05742f107821e65c63ab34650849e3f883c60..ab6fd7853cd56bb255365cb4e9cb68704e6bd45b 100644 (file)
@@ -85,7 +85,7 @@ private:
        void text (PlayerText pt, TextType type, boost::optional<DCPTextTrack> track, dcpomatic::DCPTimePeriod period);
        bool should_run () const;
        void prepare (boost::weak_ptr<PlayerVideo> video);
-       void player_change (ChangeType type);
+       void player_change (ChangeType type, int property);
        void seek_unlocked (dcpomatic::DCPTime position, bool accurate);
 
        boost::weak_ptr<const Film> _film;
index 4417c940d5671efaee74f4f24e68af615984b497..7899f2e83eb4139f62157399608e59dd063c50ca 100644 (file)
@@ -280,18 +280,28 @@ Player::setup_pieces_unlocked ()
 void
 Player::playlist_content_change (ChangeType type, int property, bool frequent)
 {
-       if (type == CHANGE_TYPE_PENDING) {
-               /* The player content is probably about to change, so we can't carry on
-                  until that has happened and we've rebuilt our pieces.  Stop pass()
-                  and seek() from working until then.
-               */
-               ++_suspended;
-       } else if (type == CHANGE_TYPE_DONE) {
-               /* A change in our content has gone through.  Re-build our pieces. */
-               setup_pieces ();
-               --_suspended;
-       } else if (type == CHANGE_TYPE_CANCELLED) {
-               --_suspended;
+       if (property == VideoContentProperty::CROP) {
+               if (type == CHANGE_TYPE_DONE) {
+                       dcp::Size const vcs = video_container_size();
+                       boost::mutex::scoped_lock lm (_mutex);
+                       for (list<pair<shared_ptr<PlayerVideo>, DCPTime> >::const_iterator i = _delay.begin(); i != _delay.end(); ++i) {
+                               i->first->reset_metadata (_film, vcs);
+                       }
+               }
+       } else {
+               if (type == CHANGE_TYPE_PENDING) {
+                       /* The player content is probably about to change, so we can't carry on
+                          until that has happened and we've rebuilt our pieces.  Stop pass()
+                          and seek() from working until then.
+                       */
+                       ++_suspended;
+               } else if (type == CHANGE_TYPE_DONE) {
+                       /* A change in our content has gone through.  Re-build our pieces. */
+                       setup_pieces ();
+                       --_suspended;
+               } else if (type == CHANGE_TYPE_CANCELLED) {
+                       --_suspended;
+               }
        }
 
        Change (type, property, frequent);