Browse Source

DSP: Added an assertion to protect against invalid use of ProcessContextNonReplacing

tags/2021-05-28
Tom Poole 6 years ago
parent
commit
9f344aaa5a
2 changed files with 20 additions and 1 deletions
  1. +14
    -0
      modules/juce_dsp/containers/juce_AudioBlock.h
  2. +6
    -1
      modules/juce_dsp/processors/juce_ProcessContext.h

+ 14
- 0
modules/juce_dsp/containers/juce_AudioBlock.h View File

@@ -151,6 +151,20 @@ public:
AudioBlock (const AudioBlock& other) noexcept = default;
AudioBlock& operator= (const AudioBlock& other) noexcept = default;
//==============================================================================
bool operator== (const AudioBlock& other) const noexcept
{
return std::equal (channels, channels + numChannels,
other.channels, other.channels + other.numChannels)
&& startSample == other.startSample
&& numSamples == other.numSamples;
}
bool operator!= (const AudioBlock& other) const noexcept
{
return ! (*this == other);
}
//==============================================================================
forcedinline size_t getNumSamples() const noexcept { return numSamples; }
forcedinline size_t getNumChannels() const noexcept { return static_cast<size_t> (numChannels); }


+ 6
- 1
modules/juce_dsp/processors/juce_ProcessContext.h View File

@@ -139,7 +139,12 @@ public:
Note that the caller must not delete these blocks while they are still in use by this object!
*/
ProcessContextNonReplacing (const AudioBlockType& input, AudioBlockType& output) noexcept
: inputBlock (input), outputBlock (output) {}
: inputBlock (input), outputBlock (output)
{
// If the input and output blocks are the same then you should use
// ProcessContextReplacing instead.
jassert (input != output);
}
ProcessContextNonReplacing (const ProcessContextNonReplacing&) = default;
ProcessContextNonReplacing (ProcessContextNonReplacing&&) = default;


Loading…
Cancel
Save