diff --git a/Outputs/Speaker/Implementation/LowpassSpeaker.hpp b/Outputs/Speaker/Implementation/LowpassSpeaker.hpp index 8d67c6f13..d446f3f9f 100644 --- a/Outputs/Speaker/Implementation/LowpassSpeaker.hpp +++ b/Outputs/Speaker/Implementation/LowpassSpeaker.hpp @@ -131,7 +131,7 @@ template class LowpassSpeaker: public Speaker { at construction, filtering it and passing it on to the speaker's delegate if there is one. */ void run_for(const Cycles cycles) { - const auto delegate = delegate_.load(); + const auto delegate = delegate_.load(std::memory_order::memory_order_relaxed); if(!delegate) return; const int scale = get_scale(); diff --git a/Outputs/Speaker/Speaker.hpp b/Outputs/Speaker/Speaker.hpp index 875a16032..511b0e337 100644 --- a/Outputs/Speaker/Speaker.hpp +++ b/Outputs/Speaker/Speaker.hpp @@ -89,7 +89,7 @@ class Speaker { virtual void speaker_did_change_input_clock([[maybe_unused]] Speaker *speaker) {} }; virtual void set_delegate(Delegate *delegate) { - delegate_ = delegate; + delegate_.store(delegate, std::memory_order::memory_order_relaxed); } @@ -99,7 +99,7 @@ class Speaker { protected: void did_complete_samples(Speaker *, const std::vector &buffer, bool is_stereo) { // Test the delegate for existence again, as it may have changed. - const auto delegate = delegate_.load(); + const auto delegate = delegate_.load(std::memory_order::memory_order_relaxed); if(!delegate) return; ++completed_sample_sets_;