From b093a8e406911b684bab5fe03b9dd377fc50dbdf Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 6 Sep 2016 07:40:49 -0400 Subject: [PATCH] SAMPLE_SIZE macro returns size_t --- src/Dependencies.cpp | 2 +- src/Mix.cpp | 2 +- src/SampleFormat.cpp | 6 +++--- src/SampleFormat.h | 6 +++--- src/Sequence.cpp | 6 +++--- src/blockfile/SimpleBlockFile.cpp | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index ec7cf7f14..a11850009 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -126,7 +126,7 @@ void FindDependencies(AudacityProject *project, continue; const wxString &fileNameStr = fileName.GetFullPath(); - int blockBytes = (SAMPLE_SIZE(format) * + auto blockBytes = (SAMPLE_SIZE(format) * aliasBlockFile->GetLength()); if (aliasedFileHash.count(fileNameStr) > 0) // Already put this AliasBlockFile in aliasedFileHash. diff --git a/src/Mix.cpp b/src/Mix.cpp index d0f697d1e..c4fc8db18 100644 --- a/src/Mix.cpp +++ b/src/Mix.cpp @@ -414,7 +414,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache, const double trackRate = track->GetRate(); const double initialWarp = mRate / mSpeed / trackRate; const double tstep = 1.0 / trackRate; - int sampleSize = SAMPLE_SIZE(floatSample); + auto sampleSize = SAMPLE_SIZE(floatSample); decltype(mMaxOut) out = 0; diff --git a/src/SampleFormat.cpp b/src/SampleFormat.cpp index 1ac38f81c..0d3bf5fb4 100644 --- a/src/SampleFormat.cpp +++ b/src/SampleFormat.cpp @@ -88,17 +88,17 @@ AUDACITY_DLL_API void DeleteSamples(samplePtr p) void ClearSamples(samplePtr src, sampleFormat format, int start, int len) { - int size = SAMPLE_SIZE(format); + auto size = SAMPLE_SIZE(format); memset(src + start*size, 0, len*size); } void ReverseSamples(samplePtr src, sampleFormat format, int start, int len) { - int size = SAMPLE_SIZE(format); + auto size = SAMPLE_SIZE(format); samplePtr first = src + start * size; samplePtr last = src + (start + len - 1) * size; - enum { fixedSize = SAMPLE_SIZE(floatSample) }; + enum : size_t { fixedSize = SAMPLE_SIZE(floatSample) }; wxASSERT(size <= fixedSize); char temp[fixedSize]; while (first < last) { diff --git a/src/SampleFormat.h b/src/SampleFormat.h index 3d6fdb6f3..9db75ae3f 100644 --- a/src/SampleFormat.h +++ b/src/SampleFormat.h @@ -29,7 +29,7 @@ typedef enum { } sampleFormat; /** \brief Return the size (in memory) of one sample (bytes) */ -#define SAMPLE_SIZE(SampleFormat) (SampleFormat >> 16) +#define SAMPLE_SIZE(SampleFormat) ( size_t{ (SampleFormat) >> 16 } ) #endif // Used to determine how to fill in empty areas of audio. @@ -39,8 +39,8 @@ typedef enum { }fillFormat; /** \brief Return the size on disk of one uncompressed sample (bytes) */ -#define SAMPLE_SIZE_DISK(SampleFormat) ((SampleFormat == int24Sample) ? \ - 3 : SAMPLE_SIZE(SampleFormat) ) +#define SAMPLE_SIZE_DISK(SampleFormat) (((SampleFormat) == int24Sample) ? \ + size_t{ 3 } : SAMPLE_SIZE(SampleFormat) ) const wxChar *GetSampleFormatStr(sampleFormat format); diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 467258cdb..19fd89497 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -480,7 +480,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src) const BlockArray &srcBlock = src->mBlock; auto addedLen = src->mNumSamples; const unsigned int srcNumBlocks = srcBlock.size(); - int sampleSize = SAMPLE_SIZE(mSampleFormat); + auto sampleSize = SAMPLE_SIZE(mSampleFormat); if (addedLen == 0 || srcNumBlocks == 0) return true; @@ -1116,7 +1116,7 @@ bool Sequence::CopyWrite(SampleBuffer &scratch, wxASSERT(start + len <= length); wxASSERT(start >= 0); - int sampleSize = SAMPLE_SIZE(mSampleFormat); + auto sampleSize = SAMPLE_SIZE(mSampleFormat); Read(scratch.ptr(), mSampleFormat, b, 0, length); memcpy(scratch.ptr() + start*sampleSize, buffer, len*sampleSize); @@ -1590,7 +1590,7 @@ bool Sequence::Delete(sampleCount start, sampleCount len) const unsigned int b0 = FindBlock(start); unsigned int b1 = FindBlock(start + len - 1); - int sampleSize = SAMPLE_SIZE(mSampleFormat); + auto sampleSize = SAMPLE_SIZE(mSampleFormat); // Special case: if the samples to DELETE are all within a single // block and the resulting length is not too small, perform the diff --git a/src/blockfile/SimpleBlockFile.cpp b/src/blockfile/SimpleBlockFile.cpp index f53397dd1..573ace72e 100644 --- a/src/blockfile/SimpleBlockFile.cpp +++ b/src/blockfile/SimpleBlockFile.cpp @@ -123,9 +123,9 @@ SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&baseFileName, mCache.active = true; mCache.needWrite = true; mCache.format = format; - mCache.sampleData = new char[sampleLen * SAMPLE_SIZE(format)]; - memcpy(mCache.sampleData, - sampleData, sampleLen * SAMPLE_SIZE(format)); + const auto sampleDataSize = sampleLen * SAMPLE_SIZE(format); + mCache.sampleData = new char[sampleDataSize]; + memcpy(mCache.sampleData, sampleData, sampleDataSize); ArrayOf cleanup; void* summaryData = BlockFile::CalcSummary(sampleData, sampleLen, format, cleanup); @@ -269,7 +269,7 @@ bool SimpleBlockFile::WriteSimpleBlockFile( } } - return true; + return true; } void SimpleBlockFile::FillCache()