From 4d49c6e02b5226147058ca8015acf0ad1f440e9b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 11 Feb 2024 13:09:30 +0100 Subject: [PATCH] Add option to stop the player using any audio processor. --- src/lib/player.cc | 12 +++++++++++- src/lib/player.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/player.cc b/src/lib/player.cc index 79b48ea71..0796fbceb 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -191,6 +191,7 @@ Player::Player(Player&& other) , _silent(std::move(other._silent)) , _active_texts(std::move(other._active_texts)) , _audio_processor(std::move(other._audio_processor)) + , _disable_audio_processor(other._disable_audio_processor) , _playback_length(other._playback_length.load()) , _subtitle_alignment(other._subtitle_alignment) { @@ -230,6 +231,7 @@ Player::operator=(Player&& other) _silent = std::move(other._silent); _active_texts = std::move(other._active_texts); _audio_processor = std::move(other._audio_processor); + _disable_audio_processor = other._disable_audio_processor; _playback_length = other._playback_length.load(); _subtitle_alignment = other._subtitle_alignment; @@ -1207,7 +1209,7 @@ Player::audio (weak_ptr weak_piece, AudioStreamPtr stream, ContentAudio c /* Process */ - if (_audio_processor) { + if (_audio_processor && !_disable_audio_processor) { content_audio.audio = _audio_processor->run(content_audio.audio, film->audio_channels()); } @@ -1631,3 +1633,11 @@ Player::signal_change(ChangeType type, int property) Change(type, property, false); } + +/** Must be called from the same thread that calls ::pass() */ +void +Player::set_disable_audio_processor() +{ + _disable_audio_processor = true; +} + diff --git a/src/lib/player.h b/src/lib/player.h index 5950b95a3..94e41bbca 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -105,6 +105,7 @@ public: void set_fast (); void set_play_referenced (); void set_dcp_decode_reduction (boost::optional reduction); + void set_disable_audio_processor(); boost::optional content_time_to_dcp (std::shared_ptr content, dcpomatic::ContentTime t) const; boost::optional dcp_to_content_time (std::shared_ptr content, dcpomatic::DCPTime t) const; @@ -243,6 +244,7 @@ private: EnumIndexedVector _active_texts; std::shared_ptr _audio_processor; + bool _disable_audio_processor = false; boost::atomic _playback_length; -- 2.30.2