mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Bug 2057 - Exporting WAV files > 4GB silently creates invalid, truncated, WAV file
This commit is contained in:
parent
d2c112600d
commit
4e89d6b0fa
@ -25,6 +25,7 @@
|
||||
|
||||
#include "sndfile.h"
|
||||
|
||||
#include "../AudacityApp.h" // for error reporting top level window.
|
||||
#include "../FileFormats.h"
|
||||
#include "../Internat.h"
|
||||
#include "../MemoryX.h"
|
||||
@ -409,10 +410,14 @@ void ExportPCM::ReportTooBigError(wxWindow * pParent)
|
||||
"Audacity cannot do this, the Export was abandoned."),
|
||||
wxT("Error_wav_too_big"));
|
||||
|
||||
// This alternative error dialog was to cover the possibility we could not
|
||||
// compute the size in advance.
|
||||
#if 0
|
||||
ShowErrorDialog(pParent, _("Error Exporting"),
|
||||
_("Your exported WAV file has been truncated as Audacity cannot export WAV\n"
|
||||
"files bigger than 4GB."),
|
||||
wxT("Error_wav_truncated"));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -509,6 +514,16 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
else
|
||||
format = int16Sample;
|
||||
|
||||
float sampleCount = (float)(t1-t0)*rate*info.channels;
|
||||
// floatSamples are always 4 byte, even if processor uses more.
|
||||
float byteCount = sampleCount * ((format==int16Sample)?2:4);
|
||||
// Test for 4 Gibibytes, rather than 4 Gigabytes
|
||||
if( byteCount > 4.295e9)
|
||||
{
|
||||
ReportTooBigError( wxGetApp().GetTopWindow() );
|
||||
return ProgressResult::Failed;
|
||||
}
|
||||
|
||||
size_t maxBlockLen = 44100 * 5;
|
||||
|
||||
const WaveTrackConstArray waveTracks =
|
||||
|
Loading…
x
Reference in New Issue
Block a user