Use atomic for _dcp_decode_reduction.
authorCarl Hetherington <cth@carlh.net>
Sat, 10 Sep 2022 16:18:45 +0000 (18:18 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 10 Sep 2022 21:21:02 +0000 (23:21 +0200)
src/lib/player.cc
src/lib/player.h

index a6cfd9367102866f75eee399421c3673dad3ea85..c3fee45b47bb17f84c5f25414d1852680886a9ce 100644 (file)
@@ -1414,19 +1414,14 @@ Player::set_dcp_decode_reduction (optional<int> reduction)
 {
        Change (ChangeType::PENDING, PlayerProperty::DCP_DECODE_REDUCTION, false);
 
-       {
-               boost::mutex::scoped_lock lm (_mutex);
-
-               if (reduction == _dcp_decode_reduction) {
-                       lm.unlock ();
-                       Change (ChangeType::CANCELLED, PlayerProperty::DCP_DECODE_REDUCTION, false);
-                       return;
-               }
-
-               _dcp_decode_reduction = reduction;
-               setup_pieces_unlocked ();
+       if (reduction == _dcp_decode_reduction.load()) {
+               Change(ChangeType::CANCELLED, PlayerProperty::DCP_DECODE_REDUCTION, false);
+               return;
        }
 
+       _dcp_decode_reduction = reduction;
+       setup_pieces();
+
        Change (ChangeType::DONE, PlayerProperty::DCP_DECODE_REDUCTION, false);
 }
 
index d586622c4a46ded11a34b540acb371cc9658d7f0..ce8b7cc5a53894fcc6d727d5ae790f393c0417f9 100644 (file)
@@ -196,7 +196,7 @@ private:
        /** Time of the next audio that we will emit, or the time of the last accurate seek */
        boost::optional<dcpomatic::DCPTime> _next_audio_time;
 
-       boost::optional<int> _dcp_decode_reduction;
+       boost::atomic<boost::optional<int>> _dcp_decode_reduction;
 
        typedef std::map<std::weak_ptr<Piece>, std::shared_ptr<PlayerVideo>, std::owner_less<std::weak_ptr<Piece>>> LastVideoMap;
        LastVideoMap _last_video;