Use atomic shared_ptr stuff for _black_frame.
authorCarl Hetherington <cth@carlh.net>
Sat, 10 Sep 2022 18:14:27 +0000 (20:14 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 10 Sep 2022 21:21:08 +0000 (23:21 +0200)
src/lib/player.cc
src/lib/player.h

index 9cc7e5d25b31567c7e80cb003000e71452aaf76a..0ff2c4032c0a2c7de5da3bdd381284e4a808feb9 100644 (file)
@@ -344,11 +344,9 @@ Player::set_video_container_size (dcp::Size s)
 
        _video_container_size = s;
 
-       {
-               boost::mutex::scoped_lock lm (_mutex);
-               _black_image = make_shared<Image>(AV_PIX_FMT_RGB24, _video_container_size, Image::Alignment::PADDED);
-               _black_image->make_black ();
-       }
+       auto black = make_shared<Image>(AV_PIX_FMT_RGB24, _video_container_size, Image::Alignment::PADDED);
+       black->make_black ();
+       std::atomic_store(&_black_image, black);
 
        Change (ChangeType::DONE, PlayerProperty::VIDEO_CONTAINER_SIZE, false);
 }
@@ -399,8 +397,10 @@ Player::film_change (ChangeType type, Film::Property p)
 shared_ptr<PlayerVideo>
 Player::black_player_video_frame (Eyes eyes) const
 {
+       auto black = std::atomic_load(&_black_image);
+
        return std::make_shared<PlayerVideo> (
-               std::make_shared<const RawImageProxy>(_black_image),
+               std::make_shared<const RawImageProxy>(black),
                Crop(),
                optional<double>(),
                _video_container_size,
index 388a160c79727e10069ed9cc8039373177ed4d08..5abd59de26a8c8fbda3940bde6d05a67077fbab1 100644 (file)
@@ -173,6 +173,7 @@ private:
         *  the size of preview in a window.
         */
        boost::atomic<dcp::Size> _video_container_size;
+       /** Should be accessed using the std::atomic... methods */
        std::shared_ptr<Image> _black_image;
 
        /** true if the player should ignore all video; i.e. never produce any */