diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/player.cc | 17 | ||||
| -rw-r--r-- | src/lib/player.h | 9 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index f93327495..dece1306c 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -164,7 +164,7 @@ Player::Player(Player&& other) , _play_referenced(other._play_referenced.load()) , _next_video_time(other._next_video_time) , _next_audio_time(other._next_audio_time) - , _dcp_decode_reduction(other._dcp_decode_reduction.load()) + , _dcp_decode_reduction(other._dcp_decode_reduction) , _last_video(std::move(other._last_video)) , _audio_merger(std::move(other._audio_merger)) , _shuffler(std::move(other._shuffler)) @@ -204,7 +204,7 @@ Player::operator=(Player&& other) _play_referenced = other._play_referenced.load(); _next_video_time = other._next_video_time; _next_audio_time = other._next_audio_time; - _dcp_decode_reduction = other._dcp_decode_reduction.load(); + _dcp_decode_reduction = other._dcp_decode_reduction; _last_video = std::move(other._last_video); _audio_merger = std::move(other._audio_merger); _shuffler = std::move(other._shuffler); @@ -1554,12 +1554,17 @@ Player::set_dcp_decode_reduction(optional<int> reduction) { ChangeSignaller<Player, int> cc(this, PlayerProperty::DCP_DECODE_REDUCTION); - if (reduction == _dcp_decode_reduction.load()) { - cc.abort(); - return; + { + boost::mutex::scoped_lock lm(_mutex); + + if (reduction == _dcp_decode_reduction) { + cc.abort(); + return; + } + + _dcp_decode_reduction = reduction; } - _dcp_decode_reduction = reduction; setup_pieces(); } diff --git a/src/lib/player.h b/src/lib/player.h index df5db28f0..2ae60c287 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -181,9 +181,10 @@ private: std::weak_ptr<Piece> weak_piece, std::weak_ptr<const TextContent> weak_content, dcpomatic::ContentTime subtitle_from ) const; - /** Mutex to protect the most of the Player state. When it's used for the preview we have - seek() and pass() called from the Butler thread and lots of other stuff called - from the GUI thread. + /** Mutex to protect the player state that is not using std::atomic. + * When the player is used for the preview we have seek() and pass() + * called from the Butler thread and lots of other stuff called + * from the GUI thread. */ mutable boost::mutex _mutex; @@ -221,7 +222,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; - std::atomic<boost::optional<int>> _dcp_decode_reduction; + boost::optional<int> _dcp_decode_reduction; EnumIndexedVector<std::pair<std::shared_ptr<PlayerVideo>, dcpomatic::DCPTime>, Eyes> _last_video; |
