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

Fixed a data race in an example

This commit is contained in:
Tom Poole 2019-06-28 10:13:06 +01:00
parent 1c9cea431d
commit d8e07dca91

View file

@ -55,8 +55,10 @@ struct AudioVisualiserComponent::ChannelInfo
{
if (--subSample <= 0)
{
nextSample %= levels.size();
levels.getReference (nextSample++) = value;
if (++nextSample == levels.size())
nextSample = 0;
levels.getReference (nextSample) = value;
subSample = owner.getSamplesPerBlock();
value = Range<float> (newSample, newSample);
}
@ -78,7 +80,7 @@ struct AudioVisualiserComponent::ChannelInfo
AudioVisualiserComponent& owner;
Array<Range<float>> levels;
Range<float> value;
int nextSample = 0, subSample = 0;
std::atomic<int> nextSample { 0 }, subSample { 0 };
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChannelInfo)
};