1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-17 08:01:12 +02: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

@@ -204,7 +204,9 @@ void ODComputeSummaryTask::Update()
const auto odpcmaFile =
std::static_pointer_cast<ODPCMAliasBlockFile>(file);
odpcmaFile->SetStart(block.start);
odpcmaFile->SetClipOffset(clip->GetStartTime()*clip->GetRate());
odpcmaFile->SetClipOffset(sampleCount(
clip->GetStartTime()*clip->GetRate()
));
//these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
while(insertCursor<(int)tempBlocks.size()&&

View File

@@ -330,7 +330,10 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo
mCurrentPos = start+len +1;
while(numAttempts++ < kMaxSeekRewindAttempts && mCurrentPos > start) {
//we want to move slightly before the start of the block file, but not too far ahead
targetts = (start-kDecodeSampleAllowance*numAttempts/kMaxSeekRewindAttempts) * ((double)st->time_base.den/(st->time_base.num * st->codec->sample_rate ));
targetts =
(start - kDecodeSampleAllowance * numAttempts / kMaxSeekRewindAttempts)
.as_long_long() *
((double)st->time_base.den/(st->time_base.num * st->codec->sample_rate ));
if(targetts<0)
targetts=0;
@@ -384,7 +387,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo
seeking = false;
}
if(actualDecodeStart != mCurrentPos)
printf("ts not matching - now:%llu , last:%llu, lastlen:%llu, start %llu, len %llu\n",actualDecodeStart, mCurrentPos, mCurrentLen, start, len);
printf("ts not matching - now:%llu , last:%llu, lastlen:%llu, start %llu, len %llu\n",actualDecodeStart.as_long_long(), mCurrentPos.as_long_long(), mCurrentLen, start.as_long_long(), len);
//if we've skipped over some samples, fill the gap with silence. This could happen often in the beginning of the file.
if(actualDecodeStart>start && firstpass) {
// find the number of samples for the leading silence

View File

@@ -194,7 +194,7 @@ int ODFlacDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCoun
static_assert(sizeof(sampleCount::type) <=
sizeof(FLAC__int64),
"Type FLAC__int64 is too narrow to hold a sampleCount");
if(!mFile->seek_absolute(start))
if(!mFile->seek_absolute(static_cast<FLAC__int64>( start.as_long_long() )))
{
mFlacFileLock.Unlock();
return -1;

View File

@@ -159,7 +159,9 @@ void ODDecodeTask::Update()
std::static_pointer_cast<ODDecodeBlockFile>(file))->GetDecodeType() == this->GetODType())
{
oddbFile->SetStart(block.start);
oddbFile->SetClipOffset(clip->GetStartTime()*clip->GetRate());
oddbFile->SetClipOffset(sampleCount(
clip->GetStartTime()*clip->GetRate()
));
//these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
while(insertCursor<(int)tempBlocks.size()&&