mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioProcessorPlayer: Resolve TSAN warnings
This commit is contained in:
parent
765eafb1eb
commit
32690e6273
1 changed files with 54 additions and 58 deletions
|
|
@ -163,39 +163,37 @@ void AudioProcessorPlayer::resizeChannels()
|
|||
|
||||
void AudioProcessorPlayer::setProcessor (AudioProcessor* const processorToPlay)
|
||||
{
|
||||
if (processor != processorToPlay)
|
||||
const ScopedLock sl (lock);
|
||||
|
||||
if (processor == processorToPlay)
|
||||
return;
|
||||
|
||||
if (processorToPlay != nullptr && sampleRate > 0 && blockSize > 0)
|
||||
{
|
||||
if (processorToPlay != nullptr && sampleRate > 0 && blockSize > 0)
|
||||
{
|
||||
defaultProcessorChannels = NumChannels { processorToPlay->getBusesLayout() };
|
||||
actualProcessorChannels = findMostSuitableLayout (*processorToPlay);
|
||||
defaultProcessorChannels = NumChannels { processorToPlay->getBusesLayout() };
|
||||
actualProcessorChannels = findMostSuitableLayout (*processorToPlay);
|
||||
|
||||
processorToPlay->setPlayConfigDetails (actualProcessorChannels.ins,
|
||||
actualProcessorChannels.outs,
|
||||
sampleRate,
|
||||
blockSize);
|
||||
processorToPlay->setPlayConfigDetails (actualProcessorChannels.ins,
|
||||
actualProcessorChannels.outs,
|
||||
sampleRate,
|
||||
blockSize);
|
||||
|
||||
auto supportsDouble = processorToPlay->supportsDoublePrecisionProcessing() && isDoublePrecision;
|
||||
auto supportsDouble = processorToPlay->supportsDoublePrecisionProcessing() && isDoublePrecision;
|
||||
|
||||
processorToPlay->setProcessingPrecision (supportsDouble ? AudioProcessor::doublePrecision
|
||||
: AudioProcessor::singlePrecision);
|
||||
processorToPlay->prepareToPlay (sampleRate, blockSize);
|
||||
}
|
||||
|
||||
AudioProcessor* oldOne = nullptr;
|
||||
|
||||
{
|
||||
const ScopedLock sl (lock);
|
||||
|
||||
oldOne = isPrepared ? processor : nullptr;
|
||||
processor = processorToPlay;
|
||||
isPrepared = true;
|
||||
resizeChannels();
|
||||
}
|
||||
|
||||
if (oldOne != nullptr)
|
||||
oldOne->releaseResources();
|
||||
processorToPlay->setProcessingPrecision (supportsDouble ? AudioProcessor::doublePrecision
|
||||
: AudioProcessor::singlePrecision);
|
||||
processorToPlay->prepareToPlay (sampleRate, blockSize);
|
||||
}
|
||||
|
||||
AudioProcessor* oldOne = nullptr;
|
||||
|
||||
oldOne = isPrepared ? processor : nullptr;
|
||||
processor = processorToPlay;
|
||||
isPrepared = true;
|
||||
resizeChannels();
|
||||
|
||||
if (oldOne != nullptr)
|
||||
oldOne->releaseResources();
|
||||
}
|
||||
|
||||
void AudioProcessorPlayer::setDoublePrecisionProcessing (bool doublePrecision)
|
||||
|
|
@ -235,13 +233,11 @@ void AudioProcessorPlayer::audioDeviceIOCallback (const float** const inputChann
|
|||
const int numOutputChannels,
|
||||
const int numSamples)
|
||||
{
|
||||
const ScopedLock sl (lock);
|
||||
|
||||
// These should have been prepared by audioDeviceAboutToStart()...
|
||||
jassert (sampleRate > 0 && blockSize > 0);
|
||||
|
||||
// The processor should be prepared to deal with the same number of output channels
|
||||
// as our output device.
|
||||
jassert (processor == nullptr || numOutputChannels == actualProcessorChannels.outs);
|
||||
|
||||
incomingMidi.clear();
|
||||
messageCollector.removeNextBlockOfMessages (incomingMidi, numSamples);
|
||||
|
||||
|
|
@ -256,42 +252,42 @@ void AudioProcessorPlayer::audioDeviceIOCallback (const float** const inputChann
|
|||
const auto totalNumChannels = jmax (actualProcessorChannels.ins, actualProcessorChannels.outs);
|
||||
AudioBuffer<float> buffer (channels.data(), (int) totalNumChannels, numSamples);
|
||||
|
||||
if (processor != nullptr)
|
||||
{
|
||||
const ScopedLock sl (lock);
|
||||
// The processor should be prepared to deal with the same number of output channels
|
||||
// as our output device.
|
||||
jassert (numOutputChannels == actualProcessorChannels.outs);
|
||||
|
||||
if (processor != nullptr)
|
||||
const ScopedLock sl2 (processor->getCallbackLock());
|
||||
|
||||
if (! processor->isSuspended())
|
||||
{
|
||||
const ScopedLock sl2 (processor->getCallbackLock());
|
||||
|
||||
if (! processor->isSuspended())
|
||||
if (processor->isUsingDoublePrecision())
|
||||
{
|
||||
if (processor->isUsingDoublePrecision())
|
||||
conversionBuffer.makeCopyOf (buffer, true);
|
||||
processor->processBlock (conversionBuffer, incomingMidi);
|
||||
buffer.makeCopyOf (conversionBuffer, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
processor->processBlock (buffer, incomingMidi);
|
||||
}
|
||||
|
||||
if (midiOutput != nullptr)
|
||||
{
|
||||
if (midiOutput->isBackgroundThreadRunning())
|
||||
{
|
||||
conversionBuffer.makeCopyOf (buffer, true);
|
||||
processor->processBlock (conversionBuffer, incomingMidi);
|
||||
buffer.makeCopyOf (conversionBuffer, true);
|
||||
midiOutput->sendBlockOfMessages (incomingMidi,
|
||||
Time::getMillisecondCounterHiRes(),
|
||||
sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
processor->processBlock (buffer, incomingMidi);
|
||||
midiOutput->sendBlockOfMessagesNow (incomingMidi);
|
||||
}
|
||||
|
||||
if (midiOutput != nullptr)
|
||||
{
|
||||
if (midiOutput->isBackgroundThreadRunning())
|
||||
{
|
||||
midiOutput->sendBlockOfMessages (incomingMidi,
|
||||
Time::getMillisecondCounterHiRes(),
|
||||
sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
midiOutput->sendBlockOfMessagesNow (incomingMidi);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue