Browse Source

Zero out buffers if pulling audio returns an error in the AU wrapper

tags/2021-05-28
hogliux 9 years ago
parent
commit
1b217d13ec
1 changed files with 5 additions and 9 deletions
  1. +5
    -9
      modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm

+ 5
- 9
modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm View File

@@ -1069,9 +1069,7 @@ public:
// prepare buffers // prepare buffers
{ {
if (! pullInputAudio (ioActionFlags, inTimeStamp, nFrames))
return noErr;
pullInputAudio (ioActionFlags, inTimeStamp, nFrames);
prepareOutputBuffers (nFrames); prepareOutputBuffers (nFrames);
audioBuffer.reset(); audioBuffer.reset();
} }
@@ -1516,23 +1514,21 @@ private:
AudioUnitHelpers::ChannelRemapper mapper; AudioUnitHelpers::ChannelRemapper mapper;
//============================================================================== //==============================================================================
bool pullInputAudio (AudioUnitRenderActionFlags& flags, const AudioTimeStamp& timestamp, const UInt32 nFrames) noexcept
void pullInputAudio (AudioUnitRenderActionFlags& flags, const AudioTimeStamp& timestamp, const UInt32 nFrames) noexcept
{ {
const unsigned int numInputBuses = GetScope (kAudioUnitScope_Input).GetNumberOfElements(); const unsigned int numInputBuses = GetScope (kAudioUnitScope_Input).GetNumberOfElements();
OSStatus err;
for (unsigned int i = 0; i < numInputBuses; ++i) for (unsigned int i = 0; i < numInputBuses; ++i)
{ {
if (AUInputElement* input = GetInput (i)) if (AUInputElement* input = GetInput (i))
{ {
if (input->PullInput (flags, timestamp, i, nFrames) != noErr)
return false; // logic sometimes doesn't connect all the inputs immedietely
err = input->PullInput (flags, timestamp, i, nFrames);
if ((flags & kAudioUnitRenderAction_OutputIsSilence) != 0)
if ((flags & kAudioUnitRenderAction_OutputIsSilence) != 0 || err != noErr)
AudioUnitHelpers::clearAudioBuffer (input->GetBufferList()); AudioUnitHelpers::clearAudioBuffer (input->GetBufferList());
} }
} }
return true;
} }
void prepareOutputBuffers (const UInt32 nFrames) noexcept void prepareOutputBuffers (const UInt32 nFrames) noexcept


Loading…
Cancel
Save