mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +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;
|
sf_format = kFormats[subformat].format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int fileFormat = sf_format & SF_FORMAT_TYPEMASK;
|
||||||
|
|
||||||
auto updateResult = ProgressResult::Success;
|
auto updateResult = ProgressResult::Success;
|
||||||
{
|
{
|
||||||
wxFile f; // will be closed when it goes out of scope
|
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,
|
//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.
|
//(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.
|
//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
|
// Use libsndfile to export file
|
||||||
|
|
||||||
@ -494,10 +497,10 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
|||||||
if (metadata == NULL)
|
if (metadata == NULL)
|
||||||
metadata = &Tags::Get( *project );
|
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)
|
// WAV and WAVEX formats)
|
||||||
if ((sf_format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAV &&
|
if (fileFormat != SF_FORMAT_WAV &&
|
||||||
(sf_format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAVEX) {
|
fileFormat != SF_FORMAT_WAVEX) {
|
||||||
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
||||||
return ProgressResult::Cancelled;
|
return ProgressResult::Cancelled;
|
||||||
}
|
}
|
||||||
@ -509,15 +512,22 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
|||||||
else
|
else
|
||||||
format = int16Sample;
|
format = int16Sample;
|
||||||
|
|
||||||
float sampleCount = (float)(t1-t0)*rate*info.channels;
|
// Bug 2200
|
||||||
float byteCount = sampleCount * sf_subtype_bytes_per_sample( info.format);
|
// Only trap size limit for file types we know have an upper size limit.
|
||||||
// Test for 4 Gibibytes, rather than 4 Gigabytes
|
// The error message mentions aiff and wav.
|
||||||
if( byteCount > 4.295e9)
|
if( (fileFormat == SF_FORMAT_WAV) ||
|
||||||
|
(fileFormat == SF_FORMAT_WAVEX) ||
|
||||||
|
(fileFormat == SF_FORMAT_AIFF ))
|
||||||
{
|
{
|
||||||
ReportTooBigError( wxTheApp->GetTopWindow() );
|
float sampleCount = (float)(t1-t0)*rate*info.channels;
|
||||||
return ProgressResult::Failed;
|
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;
|
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
|
// Install the WAV metata in a "LIST" chunk at the end of the file
|
||||||
if (updateResult == ProgressResult::Success ||
|
if (updateResult == ProgressResult::Success ||
|
||||||
updateResult == ProgressResult::Stopped) {
|
updateResult == ProgressResult::Stopped) {
|
||||||
if ((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
|
if (fileFormat == SF_FORMAT_WAV ||
|
||||||
(sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAVEX) {
|
fileFormat == SF_FORMAT_WAVEX) {
|
||||||
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
||||||
// TODO: more precise message
|
// TODO: more precise message
|
||||||
AudacityMessageBox(_("Unable to export"));
|
AudacityMessageBox(_("Unable to export"));
|
||||||
@ -588,8 +598,8 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
|||||||
|
|
||||||
if (updateResult == ProgressResult::Success ||
|
if (updateResult == ProgressResult::Success ||
|
||||||
updateResult == ProgressResult::Stopped)
|
updateResult == ProgressResult::Stopped)
|
||||||
if (((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_AIFF) ||
|
if ((fileFormat == SF_FORMAT_AIFF) ||
|
||||||
((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV))
|
(fileFormat == SF_FORMAT_WAV))
|
||||||
// Note: file has closed, and gets reopened and closed again here:
|
// Note: file has closed, and gets reopened and closed again here:
|
||||||
if (!AddID3Chunk(fName, metadata, sf_format) ) {
|
if (!AddID3Chunk(fName, metadata, sf_format) ) {
|
||||||
// TODO: more precise message
|
// TODO: more precise message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user