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

ARAAudioSourceReader: Fix data race

Prior to this fix a data race could occur on 
ARAAudioSourceReader::hostReader between the functions 
didEnableAudioSourceSamplesAccess() and readSamples().
This commit is contained in:
Dan Raviv 2022-11-13 12:25:21 -08:00 committed by Attila Szarvas
parent bb8fe938d8
commit 180bbce579

View file

@ -121,11 +121,11 @@ bool ARAAudioSourceReader::readSamples (int* const* destSamples, int numDestChan
const auto destSize = (bitsPerSample / 8) * (size_t) numSamples; const auto destSize = (bitsPerSample / 8) * (size_t) numSamples;
const auto bufferOffset = (int) (bitsPerSample / 8) * startOffsetInDestBuffer; const auto bufferOffset = (int) (bitsPerSample / 8) * startOffsetInDestBuffer;
if (isValid() && hostReader != nullptr) if (isValid())
{ {
const ScopedTryReadLock readLock (lock); const ScopedTryReadLock readLock (lock);
if (readLock.isLocked()) if (readLock.isLocked() && hostReader != nullptr)
{ {
for (size_t i = 0; i < tmpPtrs.size(); ++i) for (size_t i = 0; i < tmpPtrs.size(); ++i)
{ {