1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 07:43:54 +02:00

Preliminaries for bug 900

Create WaveTrackCache as a utility class but don't use it anywhere yet.

The possible minor performance problem with effects is fixed by changes
in WaveTrack::GetBestBlockSize().
This commit is contained in:
Paul-Licameli
2015-03-28 14:46:40 -04:00
committed by Paul Licameli
parent 16e0fe3e12
commit bdc2839112
17 changed files with 365 additions and 60 deletions

View File

@@ -51,6 +51,46 @@ const wxChar *GetSampleFormatStr(sampleFormat format);
AUDACITY_DLL_API samplePtr NewSamples(int count, sampleFormat format);
AUDACITY_DLL_API void DeleteSamples(samplePtr p);
// RAII version of above
class SampleBuffer {
public:
SampleBuffer()
: mCount(0), mPtr(0)
{}
SampleBuffer(int count, sampleFormat format)
: mCount(count), mPtr(NewSamples(mCount, format))
{}
~SampleBuffer()
{
Free();
}
// WARNING! May not preserve contents.
void Resize(int count, sampleFormat format)
{
if (mCount < count) {
Free();
mPtr = NewSamples(count, format);
mCount = count;
}
}
void Free()
{
DeleteSamples(mPtr);
mPtr = 0;
mCount = 0;
}
samplePtr ptr() const { return mPtr; }
private:
samplePtr mPtr;
int mCount;
};
//
// Copying, Converting and Clearing Samples
//