1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-04-05 22:07:42 +02:00

Make many conversions sampleCount->size_t are explicit and checked...

... with run-time assertions.

I examined each place and reasoned that the narrowing was safe, and commented
why so.

Again, there are places where the sampleCount variable will later be changed
to have a different type, and they are not changed here.
This commit is contained in:
Paul Licameli
2016-08-31 00:49:22 -04:00
parent 78be459fa1
commit 078ff056e2
17 changed files with 220 additions and 77 deletions

View File

@@ -103,7 +103,8 @@ bool EffectRepair::Process()
const auto s0 = track->TimeToLongSamples(t0);
const auto s1 = track->TimeToLongSamples(t1);
const auto repairStart = (repair0 - s0);
// The difference is at most 2 * 128:
const auto repairStart = (repair0 - s0).as_size_t();
const auto len = s1 - s0;
if (s0 == repair0 && s1 == repair1) {
@@ -113,8 +114,12 @@ bool EffectRepair::Process()
break;
}
if (!ProcessOne(count, track,
s0, len, repairStart, repairLen)) {
if (!ProcessOne(count, track, s0,
// len is at most 5 * 128.
len.as_size_t(),
repairStart,
// repairLen is at most 128.
repairLen.as_size_t() )) {
bGoodResult = false;
break;
}