From ce20ab8a3b868f0c9445ae3d83e861edd80bde21 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 1 Apr 2019 17:16:16 +0100 Subject: [PATCH] Made AudioBuffer::isClear atomic to fix a potential data race when used from multiple threads --- modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index 9072ae97aa..cd7fc12026 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -180,7 +180,7 @@ public: size (other.size), allocatedBytes (other.allocatedBytes), allocatedData (std::move (other.allocatedData)), - isClear (other.isClear) + isClear (other.isClear.load()) { if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) { @@ -206,7 +206,7 @@ public: size = other.size; allocatedBytes = other.allocatedBytes; allocatedData = std::move (other.allocatedData); - isClear = other.isClear; + isClear = other.isClear.load(); if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) { @@ -1071,7 +1071,7 @@ private: Type** channels; HeapBlock allocatedData; Type* preallocatedChannelSpace[32]; - bool isClear = false; + std::atomic isClear { false }; void allocateData() {