1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 08:38:39 +02:00

Bug1632: correct length of non-WAV exports >= 2^32 samples long...

... WAV format simply can't do that, others (FLAC, ogg, mp3) can and should

Some history:

This got broken very badly for an interim starting at
919d77d1760bab320ae963e1e54fc6e4981b6000.
Exported files were only tens of bytes!

This was broken differently after
ad04187a4122556c9a91ce1ac6d6a7cf3b4162ac with symptoms as in the bug report.
This commit is contained in:
Paul Licameli 2017-07-18 11:50:20 -04:00
parent 4925d0a54b
commit fcd175183f

View File

@ -540,7 +540,6 @@ size_t Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache,
sampleCount *pos) sampleCount *pos)
{ {
const WaveTrack *const track = cache.GetTrack(); const WaveTrack *const track = cache.GetTrack();
auto slen = mMaxOut;
const double t = ( *pos ).as_double() / track->GetRate(); const double t = ( *pos ).as_double() / track->GetRate();
const double trackEndTime = track->GetEndTime(); const double trackEndTime = track->GetEndTime();
const double trackStartTime = track->GetStartTime(); const double trackStartTime = track->GetStartTime();
@ -553,10 +552,13 @@ size_t Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache,
if ((backwards ? t <= tEnd : t >= tEnd)) if ((backwards ? t <= tEnd : t >= tEnd))
return 0; return 0;
//if we're about to approach the end of the track or selection, figure out how much we need to grab //if we're about to approach the end of the track or selection, figure out how much we need to grab
slen = std::min<decltype(slen)>( slen, auto slen = limitSampleBufferSize(
((backwards ? t - tEnd : tEnd - t) * track->GetRate() + 0.5) mMaxOut,
// PRL: maybe t and tEnd should be given as sampleCount instead to
// avoid trouble subtracting one large value from another for a small
// difference
sampleCount{ (backwards ? t - tEnd : tEnd - t) * track->GetRate() + 0.5 }
); );
slen = std::min(slen, mMaxOut);
if (backwards) { if (backwards) {
auto results = cache.Get(floatSample, *pos - (slen - 1), slen, mMayThrow); auto results = cache.Get(floatSample, *pos - (slen - 1), slen, mMayThrow);