1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 00:03:52 +02:00

Common function limits buffer size to sampleCount known to be small

This commit is contained in:
Paul Licameli
2016-08-21 18:05:43 -04:00
parent 367ed1dfce
commit 1281f1b14b
31 changed files with 161 additions and 226 deletions

View File

@@ -448,9 +448,10 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
memmove(queue, &queue[*queueStart], (*queueLen) * sampleSize);
*queueStart = 0;
int getLen =
std::min((backwards ? *pos - endPos : endPos - *pos),
sampleCount(mQueueMaxLen - *queueLen));
const auto getLen = limitSampleBufferSize(
mQueueMaxLen - *queueLen,
backwards ? *pos - endPos : endPos - *pos
);
// Nothing to do if past end of play interval
if (getLen > 0) {
@@ -475,7 +476,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
*pos += getLen;
}
for (int i = 0; i < getLen; i++) {
for (decltype(+getLen) i = 0; i < getLen; i++) {
queue[(*queueLen) + i] *= mEnvValues[i];
}