1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 07:13:49 +01:00

Convert sampleCount <-> floating or -> long long explicitly ...

... A non-narrowing conversion out to long long is a necessity, but the
conversions to float and double are simply conveniences.

Conversion from floating is explicit, to avoid unintended consequences with
arithmetic operators, when later sampleCount ceases to be an alias for an
integral type.

Some conversions are not made explicit, where I expect to change the type of
the variable later to have mere size_t width.
This commit is contained in:
Paul Licameli
2016-08-25 08:53:59 -04:00
parent 99dca62cff
commit 78be459fa1
53 changed files with 329 additions and 207 deletions

View File

@@ -69,7 +69,7 @@ void LegacyAliasBlockFile::SaveXML(XMLWriter &xmlFile)
xmlFile.WriteAttr(wxT("name"), mFileName.GetFullName());
xmlFile.WriteAttr(wxT("aliaspath"), mAliasedFileName.GetFullPath());
xmlFile.WriteAttr(wxT("aliasstart"),
static_cast<long long>( mAliasStart ));
mAliasStart.as_long_long() );
xmlFile.WriteAttr(wxT("aliaslen"), mLen);
xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
xmlFile.WriteAttr(wxT("summarylen"), mSummaryInfo.totalSummaryBytes);

View File

@@ -209,7 +209,7 @@ void ODDecodeBlockFile::SaveXML(XMLWriter &xmlFile)
LockRead();
xmlFile.WriteAttr(wxT("audiofile"), mAudioFileName.GetFullPath());
xmlFile.WriteAttr(wxT("aliasstart"),
static_cast<long long>( mAliasStart ));
mAliasStart.as_long_long());
xmlFile.WriteAttr(wxT("aliaslen"), mLen);
xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
xmlFile.WriteAttr(wxT("decodetype"), (size_t)mType);

View File

@@ -248,7 +248,7 @@ void ODPCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
xmlFile.WriteAttr(wxT("aliasfile"), mAliasedFileName.GetFullPath());
xmlFile.WriteAttr(wxT("aliasstart"),
static_cast<long long>( mAliasStart));
mAliasStart.as_long_long());
xmlFile.WriteAttr(wxT("aliaslen"), mLen);
xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
@@ -531,7 +531,8 @@ int ODPCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format,
// Third party library has its own type alias, check it
static_assert(sizeof(sampleCount::type) <= sizeof(sf_count_t),
"Type sf_count_t is too narrow to hold a sampleCount");
SFCall<sf_count_t>(sf_seek, sf.get(), mAliasStart + start, SEEK_SET);
SFCall<sf_count_t>(sf_seek, sf.get(),
( mAliasStart + start ).as_long_long(), SEEK_SET);
wxASSERT(info.channels >= 0);
SampleBuffer buffer(len * info.channels, floatSample);

View File

@@ -119,7 +119,8 @@ int PCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format,
// Third party library has its own type alias, check it
static_assert(sizeof(sampleCount::type) <= sizeof(sf_count_t),
"Type sf_count_t is too narrow to hold a sampleCount");
SFCall<sf_count_t>(sf_seek, sf.get(), mAliasStart + start, SEEK_SET);
SFCall<sf_count_t>(sf_seek, sf.get(),
( mAliasStart + start ).as_long_long(), SEEK_SET);
wxASSERT(info.channels >= 0);
SampleBuffer buffer(len * info.channels, floatSample);
@@ -170,7 +171,7 @@ void PCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
xmlFile.WriteAttr(wxT("summaryfile"), mFileName.GetFullName());
xmlFile.WriteAttr(wxT("aliasfile"), mAliasedFileName.GetFullPath());
xmlFile.WriteAttr(wxT("aliasstart"),
static_cast<long long>( mAliasStart ));
mAliasStart.as_long_long());
xmlFile.WriteAttr(wxT("aliaslen"), mLen);
xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
xmlFile.WriteAttr(wxT("min"), mMin);