1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-16 17:41:14 +01:00

More uses of SampleBuffer, eliminating explicit DeleteSamples calls

This commit is contained in:
Paul Licameli
2016-02-01 10:16:00 -05:00
parent 508286661a
commit 321d5259a2
22 changed files with 145 additions and 156 deletions

View File

@@ -68,7 +68,7 @@ public:
///this->ReadData(sampleData, floatSample, 0, mLen);
///This class should call ReadHeader() first, so it knows the length, and can prepare
///the file object if it needs to.
virtual int Decode(samplePtr & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel);
virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel);
///This is a must implement abstract virtual in the superclass.
///However it doesn't do anything because ImportFFMpeg does all that for us.
@@ -296,12 +296,12 @@ ODFFmpegDecoder::~ODFFmpegDecoder()
#define kDecodeSampleAllowance 400000
//number of jump backwards seeks
#define kMaxSeekRewindAttempts 8
int ODFFmpegDecoder::Decode(samplePtr & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel)
int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel)
{
format = mScs[mStreamIndex]->m_osamplefmt;
data = NewSamples(len, format);
samplePtr bufStart = data;
data.Allocate(len, format);
samplePtr bufStart = data.ptr();
streamContext* sc = NULL;
// printf("start %llu len %llu\n", start, len);

View File

@@ -166,7 +166,7 @@ FLAC__StreamDecoderWriteStatus ODFLACFile::write_callback(const FLAC__Frame *fra
///this->ReadData(sampleData, floatSample, 0, mLen);
///This class should call ReadHeader() first, so it knows the length, and can prepare
///the file object if it needs to.
int ODFlacDecoder::Decode(samplePtr & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel)
int ODFlacDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel)
{
//we need to lock this so the target stays fixed over the seek/write callback.
@@ -182,8 +182,8 @@ int ODFlacDecoder::Decode(samplePtr & data, sampleFormat & format, sampleCount s
mDecodeBufferWritePosition=0;
mDecodeBufferLen = len;
data = NewSamples(len, mFormat);
mDecodeBuffer=data;
data.Allocate(len, mFormat);
mDecodeBuffer = data.ptr();
format = mFormat;
mTargetChannel=channel;

View File

@@ -106,7 +106,7 @@ public:
///this->ReadData(sampleData, floatSample, 0, mLen);
///This class should call ReadHeader() first, so it knows the length, and can prepare
///the file object if it needs to.
virtual int Decode(samplePtr & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel);
virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel);
///Read header. Subclasses must override. Probably should save the info somewhere.

View File

@@ -117,7 +117,7 @@ public:
///This class should call ReadHeader() first, so it knows the length, and can prepare
///the file object if it needs to.
///returns negative value for failure, 0 or positive value for success.
virtual int Decode(samplePtr & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel)=0;
virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel)=0;
wxString GetFileName(){return mFName;}