1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-09 14:43:57 +01:00

Exception safety in: some effects and generators...

... Those that directly call WaveTrack functions in their Process() routines,
which might throw exceptions for disk space exhaustion.
This commit is contained in:
Paul Licameli
2016-12-15 07:30:14 -05:00
parent 1fad6292a2
commit 22a12c6852
15 changed files with 106 additions and 97 deletions

View File

@@ -224,7 +224,6 @@ bool EffectNoiseRemoval::Process()
auto len = end - start;
if (!ProcessOne(count, track, start, len)) {
Cleanup();
bGoodResult = false;
break;
}
@@ -238,8 +237,6 @@ bool EffectNoiseRemoval::Process()
mDoProfile = false;
}
if (bGoodResult)
Cleanup();
this->ReplaceProcessedTracks(bGoodResult);
return bGoodResult;
}
@@ -305,7 +302,7 @@ void EffectNoiseRemoval::Initialize()
}
}
void EffectNoiseRemoval::Cleanup()
void EffectNoiseRemoval::End()
{
hFFT.reset();
@@ -322,6 +319,8 @@ void EffectNoiseRemoval::Cleanup()
mInWaveBuffer.reset();
mWindow.reset();
mOutOverlapBuffer.reset();
mOutputTrack.reset();
}
void EffectNoiseRemoval::StartNewTrack()
@@ -579,9 +578,6 @@ bool EffectNoiseRemoval::ProcessOne(int count, WaveTrack * track,
bool bResult = track->ClearAndPaste(t0, t0 + tLen, mOutputTrack.get(), true, false);
wxASSERT(bResult); // TO DO: Actually handle this.
}
// Delete the outputTrack now that its data is inserted in place
mOutputTrack.reset();
}
return bLoopSuccess;
@@ -688,14 +684,16 @@ void NoiseRemovalDialog::OnPreview(wxCommandEvent & WXUNUSED(event))
m_pEffect->mFreqSmoothingHz = mFreq;
m_pEffect->mAttackDecayTime = mTime;
m_pEffect->Preview();
auto cleanup = finally( [&] {
m_pEffect->mSensitivity = oldSensitivity;
m_pEffect->mNoiseGain = oldGain;
m_pEffect->mFreqSmoothingHz = oldFreq;
m_pEffect->mAttackDecayTime = oldTime;
m_pEffect->mbLeaveNoise = oldLeaveNoise;
m_pEffect->mDoProfile = oldDoProfile;
} );
m_pEffect->mSensitivity = oldSensitivity;
m_pEffect->mNoiseGain = oldGain;
m_pEffect->mFreqSmoothingHz = oldFreq;
m_pEffect->mAttackDecayTime = oldTime;
m_pEffect->mbLeaveNoise = oldLeaveNoise;
m_pEffect->mDoProfile = oldDoProfile;
m_pEffect->Preview();
}
void NoiseRemovalDialog::OnRemoveNoise( wxCommandEvent & WXUNUSED(event))