1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Made AudioBuffer::isClear atomic to fix a potential data race when used from multiple threads

This commit is contained in:
ed 2019-04-01 17:16:16 +01:00
parent fb5cfcd606
commit ce20ab8a3b

View file

@ -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<char, true> allocatedData;
Type* preallocatedChannelSpace[32];
bool isClear = false;
std::atomic<bool> isClear { false };
void allocateData()
{