mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-23 16:08:07 +02:00
Bug 2200 - Uncompressed exports in formats that have no (realistic) size restriction fail the 4GB trap for WAV & AIFF
This commit is contained in:
parent
6e5437587b
commit
da5d049fa0
@ -444,6 +444,9 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
sf_format = kFormats[subformat].format;
|
||||
}
|
||||
|
||||
|
||||
int fileFormat = sf_format & SF_FORMAT_TYPEMASK;
|
||||
|
||||
auto updateResult = ProgressResult::Success;
|
||||
{
|
||||
wxFile f; // will be closed when it goes out of scope
|
||||
@ -456,7 +459,7 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
//This whole operation should not occur while a file is being loaded on OD,
|
||||
//(we are worried about reading from a file being written to,) so we block.
|
||||
//Furthermore, we need to do this because libsndfile is not threadsafe.
|
||||
formatStr = SFCall<wxString>(sf_header_name, sf_format & SF_FORMAT_TYPEMASK);
|
||||
formatStr = SFCall<wxString>(sf_header_name, fileFormat);
|
||||
|
||||
// Use libsndfile to export file
|
||||
|
||||
@ -494,10 +497,10 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
if (metadata == NULL)
|
||||
metadata = &Tags::Get( *project );
|
||||
|
||||
// Install the metata at the beginning of the file (except for
|
||||
// Install the meta data at the beginning of the file (except for
|
||||
// WAV and WAVEX formats)
|
||||
if ((sf_format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAV &&
|
||||
(sf_format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAVEX) {
|
||||
if (fileFormat != SF_FORMAT_WAV &&
|
||||
fileFormat != SF_FORMAT_WAVEX) {
|
||||
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
@ -509,15 +512,22 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
else
|
||||
format = int16Sample;
|
||||
|
||||
float sampleCount = (float)(t1-t0)*rate*info.channels;
|
||||
float byteCount = sampleCount * sf_subtype_bytes_per_sample( info.format);
|
||||
// Test for 4 Gibibytes, rather than 4 Gigabytes
|
||||
if( byteCount > 4.295e9)
|
||||
// Bug 2200
|
||||
// Only trap size limit for file types we know have an upper size limit.
|
||||
// The error message mentions aiff and wav.
|
||||
if( (fileFormat == SF_FORMAT_WAV) ||
|
||||
(fileFormat == SF_FORMAT_WAVEX) ||
|
||||
(fileFormat == SF_FORMAT_AIFF ))
|
||||
{
|
||||
ReportTooBigError( wxTheApp->GetTopWindow() );
|
||||
return ProgressResult::Failed;
|
||||
float sampleCount = (float)(t1-t0)*rate*info.channels;
|
||||
float byteCount = sampleCount * sf_subtype_bytes_per_sample( info.format);
|
||||
// Test for 4 Gibibytes, rather than 4 Gigabytes
|
||||
if( byteCount > 4.295e9)
|
||||
{
|
||||
ReportTooBigError( wxTheApp->GetTopWindow() );
|
||||
return ProgressResult::Failed;
|
||||
}
|
||||
}
|
||||
|
||||
size_t maxBlockLen = 44100 * 5;
|
||||
|
||||
{
|
||||
@ -570,8 +580,8 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
// Install the WAV metata in a "LIST" chunk at the end of the file
|
||||
if (updateResult == ProgressResult::Success ||
|
||||
updateResult == ProgressResult::Stopped) {
|
||||
if ((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
|
||||
(sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAVEX) {
|
||||
if (fileFormat == SF_FORMAT_WAV ||
|
||||
fileFormat == SF_FORMAT_WAVEX) {
|
||||
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
||||
// TODO: more precise message
|
||||
AudacityMessageBox(_("Unable to export"));
|
||||
@ -588,8 +598,8 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
|
||||
if (updateResult == ProgressResult::Success ||
|
||||
updateResult == ProgressResult::Stopped)
|
||||
if (((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_AIFF) ||
|
||||
((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV))
|
||||
if ((fileFormat == SF_FORMAT_AIFF) ||
|
||||
(fileFormat == SF_FORMAT_WAV))
|
||||
// Note: file has closed, and gets reopened and closed again here:
|
||||
if (!AddID3Chunk(fName, metadata, sf_format) ) {
|
||||
// TODO: more precise message
|
||||
|
Loading…
x
Reference in New Issue
Block a user