require unsigned arguments for Array(s)Of::reinit
This commit is contained in:
parent
ef2b747c16
commit
aebaaf46a0
|
@ -349,7 +349,7 @@ void BlockFile::FixSummary(void *data)
|
|||
|
||||
if (min != summary64K[0] || max != summary64K[1] || bad > 0) {
|
||||
unsigned int *buffer = (unsigned int *)data;
|
||||
int len = mSummaryInfo.totalSummaryBytes / 4;
|
||||
auto len = mSummaryInfo.totalSummaryBytes / 4;
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
buffer[i] = wxUINT32_SWAP_ALWAYS(buffer[i]);
|
||||
|
@ -735,7 +735,7 @@ bool AliasBlockFile::ReadSummary(void *data)
|
|||
if (!summaryFile.IsOpened()){
|
||||
|
||||
// NEW model; we need to return valid data
|
||||
memset(data, 0, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
memset(data, 0, mSummaryInfo.totalSummaryBytes);
|
||||
|
||||
// we silence the logging for this operation in this object
|
||||
// after first occurrence of error; it's already reported and
|
||||
|
@ -748,7 +748,7 @@ bool AliasBlockFile::ReadSummary(void *data)
|
|||
else mSilentLog = FALSE; // worked properly, any future error is NEW
|
||||
}
|
||||
|
||||
int read = summaryFile.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
auto read = summaryFile.Read(data, mSummaryInfo.totalSummaryBytes);
|
||||
|
||||
FixSummary(data);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class SummaryInfo {
|
|||
int offset64K;
|
||||
size_t frames256;
|
||||
int offset256;
|
||||
int totalSummaryBytes;
|
||||
size_t totalSummaryBytes;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace std {
|
|||
using std::tr1::weak_ptr;
|
||||
using std::tr1::static_pointer_cast;
|
||||
using std::tr1::remove_reference;
|
||||
using std::tr1::is_unsigned;
|
||||
|
||||
template<typename X> struct default_delete
|
||||
{
|
||||
|
@ -160,7 +161,7 @@ namespace std {
|
|||
// Skip the self-assignment test -- self-assignment should go to the non-template overload
|
||||
get_deleter()(p);
|
||||
p = that.release();
|
||||
((D&)*this) = move(that.get_deleter());
|
||||
get_deleter() = move(that.get_deleter());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -439,11 +440,15 @@ class ArrayOf : public std::unique_ptr<X[]>
|
|||
{
|
||||
public:
|
||||
ArrayOf() {}
|
||||
explicit ArrayOf(size_t count, bool initialize = false)
|
||||
|
||||
template<typename Integral>
|
||||
explicit ArrayOf(Integral count, bool initialize = false)
|
||||
{
|
||||
static_assert(std::is_unsigned<Integral>::value, "Unsigned arguments only");
|
||||
reinit(count, initialize);
|
||||
}
|
||||
ArrayOf(const ArrayOf&) = delete;
|
||||
|
||||
ArrayOf(const ArrayOf&) PROHIBITED;
|
||||
ArrayOf(ArrayOf&& that)
|
||||
: std::unique_ptr < X[] >
|
||||
(std::move((std::unique_ptr < X[] >&)(that)))
|
||||
|
@ -460,11 +465,16 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
void reinit(size_t count, bool initialize = false)
|
||||
template< typename Integral >
|
||||
void reinit(Integral count,
|
||||
bool initialize = false)
|
||||
{
|
||||
static_assert(std::is_unsigned<Integral>::value, "Unsigned arguments only");
|
||||
if (initialize)
|
||||
// Initialize elements (usually, to zero for a numerical type)
|
||||
std::unique_ptr<X[]>::reset(safenew X[count]{});
|
||||
else
|
||||
// Avoid the slight initialization overhead
|
||||
std::unique_ptr<X[]>::reset(safenew X[count]);
|
||||
}
|
||||
};
|
||||
|
@ -480,16 +490,23 @@ class ArraysOf : public ArrayOf<ArrayOf<X>>
|
|||
{
|
||||
public:
|
||||
ArraysOf() {}
|
||||
explicit ArraysOf(size_t N)
|
||||
|
||||
template<typename Integral>
|
||||
explicit ArraysOf(Integral N)
|
||||
: ArrayOf<ArrayOf<X>>( N )
|
||||
{}
|
||||
ArraysOf(size_t N, size_t M, bool initialize = false)
|
||||
: ArrayOf<ArrayOf<X>>( N )
|
||||
|
||||
template<typename Integral1, typename Integral2 >
|
||||
ArraysOf(Integral1 N, Integral2 M, bool initialize = false)
|
||||
: ArrayOf<ArrayOf<X>>( N )
|
||||
{
|
||||
static_assert(std::is_unsigned<Integral1>::value, "Unsigned arguments only");
|
||||
static_assert(std::is_unsigned<Integral2>::value, "Unsigned arguments only");
|
||||
for (size_t ii = 0; ii < N; ++ii)
|
||||
(*this)[ii] = ArrayOf<X>{ M, initialize };
|
||||
}
|
||||
ArraysOf(const ArraysOf&) = delete;
|
||||
|
||||
ArraysOf(const ArraysOf&) PROHIBITED;
|
||||
ArraysOf& operator= (ArraysOf&& that)
|
||||
{
|
||||
ArrayOf<ArrayOf<X>>::operator=(std::move(that));
|
||||
|
@ -497,8 +514,12 @@ public:
|
|||
}
|
||||
|
||||
using ArrayOf<ArrayOf<X>>::reinit;
|
||||
void reinit(size_t countN, size_t countM, bool initialize = false)
|
||||
|
||||
template<typename Integral1, typename Integral2 >
|
||||
void reinit(Integral1 countN, Integral2 countM, bool initialize = false)
|
||||
{
|
||||
static_assert(std::is_unsigned<Integral1>::value, "Unsigned arguments only");
|
||||
static_assert(std::is_unsigned<Integral2>::value, "Unsigned arguments only");
|
||||
reinit(countN, false);
|
||||
for (size_t ii = 0; ii < countN; ++ii)
|
||||
(*this)[ii].reinit(countM, initialize);
|
||||
|
|
|
@ -159,7 +159,7 @@ LegacyBlockFile::~LegacyBlockFile()
|
|||
bool LegacyBlockFile::ReadSummary(void *data)
|
||||
{
|
||||
wxFFile summaryFile(mFileName.GetFullPath(), wxT("rb"));
|
||||
int read;
|
||||
size_t read;
|
||||
{
|
||||
Maybe<wxLogNull> silence{};
|
||||
if (mSilentLog)
|
||||
|
@ -167,14 +167,14 @@ bool LegacyBlockFile::ReadSummary(void *data)
|
|||
|
||||
if (!summaryFile.IsOpened()){
|
||||
|
||||
memset(data, 0, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
memset(data, 0, mSummaryInfo.totalSummaryBytes);
|
||||
|
||||
mSilentLog = TRUE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
read = summaryFile.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
read = summaryFile.Read(data, mSummaryInfo.totalSummaryBytes);
|
||||
}
|
||||
mSilentLog=FALSE;
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ bool ODDecodeBlockFile::ReadSummary(void *data)
|
|||
if(IsSummaryAvailable())
|
||||
return SimpleBlockFile::ReadSummary(data);
|
||||
|
||||
memset(data, 0, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
memset(data, 0, mSummaryInfo.totalSummaryBytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ bool ODPCMAliasBlockFile::ReadSummary(void *data)
|
|||
if( !summaryFile.IsOpened() ){
|
||||
|
||||
// NEW model; we need to return valid data
|
||||
memset(data,0,(size_t)mSummaryInfo.totalSummaryBytes);
|
||||
memset(data, 0, mSummaryInfo.totalSummaryBytes);
|
||||
|
||||
// we silence the logging for this operation in this object
|
||||
// after first occurrence of error; it's already reported and
|
||||
|
@ -529,9 +529,11 @@ bool ODPCMAliasBlockFile::ReadSummary(void *data)
|
|||
mFileNameMutex.Unlock();
|
||||
return true;
|
||||
|
||||
}else mSilentLog=FALSE; // worked properly, any future error is NEW
|
||||
}
|
||||
else
|
||||
mSilentLog=FALSE; // worked properly, any future error is NEW
|
||||
|
||||
int read = summaryFile.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
auto read = summaryFile.Read(data, mSummaryInfo.totalSummaryBytes);
|
||||
|
||||
FixSummary(data);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ SilentBlockFile::~SilentBlockFile()
|
|||
|
||||
bool SilentBlockFile::ReadSummary(void *data)
|
||||
{
|
||||
memset(data, 0, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
memset(data, 0, mSummaryInfo.totalSummaryBytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&baseFileName,
|
|||
format, cleanup);
|
||||
mCache.summaryData = new char[mSummaryInfo.totalSummaryBytes];
|
||||
memcpy(mCache.summaryData, summaryData,
|
||||
(size_t)mSummaryInfo.totalSummaryBytes);
|
||||
mSummaryInfo.totalSummaryBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,9 +346,10 @@ bool SimpleBlockFile::ReadSummary(void *data)
|
|||
if (mCache.active)
|
||||
{
|
||||
//wxLogDebug("SimpleBlockFile::ReadSummary(): Summary is already in cache.");
|
||||
memcpy(data, mCache.summaryData, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
memcpy(data, mCache.summaryData, mSummaryInfo.totalSummaryBytes);
|
||||
return true;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
//wxLogDebug("SimpleBlockFile::ReadSummary(): Reading summary from disk.");
|
||||
|
||||
|
@ -361,7 +362,7 @@ bool SimpleBlockFile::ReadSummary(void *data)
|
|||
// FIXME: TRAP_ERR no report to user of absent summary files?
|
||||
// filled with zero instead.
|
||||
if (!file.IsOpened()){
|
||||
memset(data, 0, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
memset(data, 0, mSummaryInfo.totalSummaryBytes);
|
||||
mSilentLog = TRUE;
|
||||
return true;
|
||||
}
|
||||
|
@ -373,7 +374,7 @@ bool SimpleBlockFile::ReadSummary(void *data)
|
|||
if( !file.Seek(sizeof(auHeader)) )
|
||||
return false;
|
||||
|
||||
int read = (int)file.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);
|
||||
auto read = file.Read(data, mSummaryInfo.totalSummaryBytes);
|
||||
|
||||
FixSummary(data);
|
||||
|
||||
|
|
|
@ -1555,7 +1555,7 @@ bool Effect::ProcessTrack(int count,
|
|||
decltype(mBufferSize) outputBufferCnt = 0;
|
||||
bool cleared = false;
|
||||
|
||||
auto chans = std::min(mNumAudioOut, mNumChannels);
|
||||
auto chans = std::min<unsigned>(mNumAudioOut, mNumChannels);
|
||||
|
||||
std::unique_ptr<WaveTrack> genLeft, genRight;
|
||||
decltype(len) genLength = 0;
|
||||
|
|
|
@ -501,8 +501,8 @@ private:
|
|||
|
||||
// For client driver
|
||||
EffectClientInterface *mClient;
|
||||
unsigned mNumAudioIn;
|
||||
unsigned mNumAudioOut;
|
||||
size_t mNumAudioIn;
|
||||
size_t mNumAudioOut;
|
||||
|
||||
float **mInBuffer;
|
||||
float **mOutBuffer;
|
||||
|
|
|
@ -392,7 +392,7 @@ bool FFmpegImportFileHandle::InitCodecs()
|
|||
{
|
||||
// Allocate the array of pointers to hold stream contexts pointers
|
||||
// Some of the allocated space may be unused (corresponds to video, subtitle, or undecodeable audio streams)
|
||||
mScs = std::make_shared<Scs>(mFormatContext->nb_streams);
|
||||
mScs = std::make_shared<Scs>(size_t{mFormatContext->nb_streams});
|
||||
// Fill the stream contexts
|
||||
for (unsigned int i = 0; i < mFormatContext->nb_streams; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue