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:
parent
1c9cea431d
commit
d8e07dca91
1 changed files with 5 additions and 3 deletions
|
|
@ -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)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue