Skip to content

Commit

Permalink
AudioProcessLoadMeasurer: Fix potential divide by zero due to uniniti…
Browse files Browse the repository at this point in the history
…alised samplesPerBlock
  • Loading branch information
reuk committed Jan 10, 2022
1 parent 77c24ae commit b0e689e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Expand Up @@ -36,6 +36,8 @@ void AudioProcessLoadMeasurer::reset (double sampleRate, int blockSize)
cpuUsageProportion = 0;
xruns = 0;

samplesPerBlock = blockSize;

if (sampleRate > 0.0 && blockSize > 0)
{
msPerSample = 1000.0 / sampleRate;
Expand Down Expand Up @@ -77,6 +79,9 @@ AudioProcessLoadMeasurer::ScopedTimer::ScopedTimer (AudioProcessLoadMeasurer& p)
AudioProcessLoadMeasurer::ScopedTimer::ScopedTimer (AudioProcessLoadMeasurer& p, int numSamplesInBlock)
: owner (p), startTime (Time::getMillisecondCounterHiRes()), samplesInBlock (numSamplesInBlock)
{
// numSamplesInBlock should never be zero. Did you remember to call AudioProcessLoadMeasurer::reset(),
// passing the expected samples per block?
jassert (numSamplesInBlock);
}

AudioProcessLoadMeasurer::ScopedTimer::~ScopedTimer()
Expand Down
Expand Up @@ -35,10 +35,6 @@ struct SimpleDeviceManagerInputLevelMeter : public Component,
inputLevelGetter = manager.getInputLevelGetter();
}

~SimpleDeviceManagerInputLevelMeter() override
{
}

void timerCallback() override
{
if (isShowing())
Expand Down

0 comments on commit b0e689e

Please sign in to comment.