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

Bug1829, more: check all errors flushing and closing export files...

... MP3 export already did this, the other five needed work.
This commit is contained in:
Paul Licameli
2018-01-22 14:52:27 -05:00
parent b3b4ace739
commit 38568f611d
11 changed files with 104 additions and 17 deletions

View File

@@ -945,6 +945,12 @@ ProgressResult ExportFFmpeg::Export(AudacityProject *project,
if ( !Finalize() ) // Finalize makes its own messages
return ProgressResult::Cancelled;
if ( mUfileCloser.close() != 0 ) {
// TODO: more precise message
AudacityMessageBox(_("Unable to export"));
return ProgressResult::Cancelled;
}
return updateResult;
}

View File

@@ -335,10 +335,13 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
mMetadata.reset();
auto cleanup2 = finally( [&] {
if (!(updateResult == ProgressResult::Success ||
updateResult == ProgressResult::Stopped)) {
#ifndef LEGACY_FLAC
f.Detach(); // libflac closes the file
f.Detach(); // libflac closes the file
#endif
encoder.finish();
encoder.finish();
}
} );
const WaveTrackConstArray waveTracks =
@@ -389,6 +392,20 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
}
}
if (updateResult == ProgressResult::Success ||
updateResult == ProgressResult::Stopped) {
#ifndef LEGACY_FLAC
f.Detach(); // libflac closes the file
#endif
if (!encoder.finish())
// Do not reassign updateResult, see cleanup2
return ProgressResult::Failed;
#ifdef LEGACY_FLAC
if (!f.Flush() || !f.Close())
return ProgressResult::Failed;
#endif
}
return updateResult;
}

View File

@@ -330,7 +330,11 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
return ProgressResult::Cancelled;
}
outFile.Close();
if ( !outFile.Close() ) {
// TODO: more precise message
AudacityMessageBox(_("Unable to export"));
return ProgressResult::Cancelled;
}
return updateResult;
}

View File

@@ -359,7 +359,11 @@ ProgressResult ExportOGG::Export(AudacityProject *project,
}
}
outFile.Close();
if ( !outFile.Close() ) {
updateResult = ProgressResult::Cancelled;
// TODO: more precise message
AudacityMessageBox(_("Unable to export"));
}
return updateResult;
}

View File

@@ -530,7 +530,7 @@ 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)
updateResult == ProgressResult::Stopped) {
if ((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
(sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAVEX) {
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
@@ -538,6 +538,12 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
AudacityMessageBox(_("Unable to export"));
return ProgressResult::Cancelled;
}
}
if (0 != sf.close()) {
// TODO: more precise message
AudacityMessageBox(_("Unable to export"));
return ProgressResult::Cancelled;
}
}
}
@@ -545,6 +551,7 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
updateResult == ProgressResult::Stopped)
if (((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_AIFF) ||
((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV))
// Note: file has closed, and gets reopened and closed again here:
if (!AddID3Chunk(fName, metadata, sf_format) ) {
// TODO: more precise message
AudacityMessageBox(_("Unable to export"));
@@ -845,6 +852,9 @@ bool ExportPCM::AddID3Chunk(wxString fName, const Tags *tags, int sf_format)
if (4 != f.Write(&sz, 4))
return false;
if (!f.Flush())
return false;
if (!f.Close())
return false;
}