1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

Bug 2515 - Exporting to a disk with insufficient space gives messages that are not user-friendly or helpful

This commit is contained in:
James Crook 2020-09-21 15:11:39 +01:00
parent 0b633c564a
commit 6149b57dc0
7 changed files with 27 additions and 17 deletions

View File

@ -1530,4 +1530,16 @@ void ShowExportErrorDialog(wxString ErrorCode,
);
}
void ShowDiskFullExportErrorDialog()
{
ShowErrorDialog(nullptr,
XO("Warning"),
XO("Audacity failed to write to a file.\n"
"Perhaps the file is not writable or the disk is full.\n"
"For tips on freeing up space, click the help button."
),
"Error:_Disk_full_or_not_writable"
);
}

View File

@ -332,5 +332,6 @@ void ShowExportErrorDialog(wxString ErrorCode,
TranslatableString message = AudacityExportMessageStr(),
const TranslatableString& caption = AudacityExportCaptionStr());
void ShowDiskFullExportErrorDialog();
#endif

View File

@ -892,6 +892,7 @@ void ExportFFmpeg::FreeResources()
av_log_set_callback(av_log_default_callback);
}
// All paths in this that fail must report their error to the user.
bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, size_t frameSize)
{
int nBytesToWrite = 0;
@ -901,14 +902,18 @@ bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, size_t frameSize)
nBytesToWrite = frameSize;
pRawSamples = (uint8_t*)pFrame;
if (av_fifo_realloc2(mEncAudioFifo.get(), av_fifo_size(mEncAudioFifo.get()) + frameSize) < 0)
if (av_fifo_realloc2(mEncAudioFifo.get(), av_fifo_size(mEncAudioFifo.get()) + frameSize) < 0) {
ShowExportErrorDialog("FFmpeg:905");
return false;
}
// Put the raw audio samples into the FIFO.
ret = av_fifo_generic_write(mEncAudioFifo.get(), pRawSamples, nBytesToWrite,NULL);
if(ret != nBytesToWrite)
if (ret != nBytesToWrite) {
ShowExportErrorDialog("FFmpeg:913");
return false;
}
if (nAudioFrameSizeOut > mEncAudioFifoOutBufSiz) {
AudacityMessageBox(
@ -954,14 +959,7 @@ bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, size_t frameSize)
// Write the encoded audio frame to the output file.
if ((ret = av_interleaved_write_frame(mEncFormatCtx.get(), &pkt)) < 0)
{
ShowErrorDialog(nullptr,
XO("Warning"),
XO("Audacity failed to write to a file.\n"
"Perhaps the file is not writable or the disk is full.\n"
"For tips on freeing up space, click the help button."
),
"Error:_Disk_full_or_not_writable"
);
ShowDiskFullExportErrorDialog();
return false;
}
}
@ -1040,9 +1038,8 @@ ProgressResult ExportFFmpeg::Export(AudacityProject *project,
if (!EncodeAudioFrame(
pcmBuffer, (pcmNumSamples)*sizeof(int16_t)*mChannels)) {
// TODO: more precise message, and fix redundancy with messages
// already given on some of the failure paths of the above call
ShowExportErrorDialog("FFmpeg:1041");
// All errors should already have been reported.
//ShowDiskFullExportErrorDialog();
updateResult = ProgressResult::Cancelled;
break;
}

View File

@ -407,7 +407,7 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
reinterpret_cast<FLAC__int32**>( tmpsmplbuf.get() ),
samplesThisRun) ) {
// TODO: more precise message
ShowExportErrorDialog("FLAC:410");
ShowDiskFullExportErrorDialog();
updateResult = ProgressResult::Cancelled;
break;
}

View File

@ -342,7 +342,7 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
if ( outFile.Write(mp2Buffer.get(), mp2BufferNumBytes).GetLastError() ) {
// TODO: more precise message
ShowExportErrorDialog("MP2:346");
ShowDiskFullExportErrorDialog();
return ProgressResult::Cancelled;
}

View File

@ -1963,7 +1963,7 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
if (bytes > (int)outFile.Write(buffer.get(), bytes)) {
// TODO: more precise message
ShowExportErrorDialog("MP3:1966");
ShowDiskFullExportErrorDialog();
updateResult = ProgressResult::Cancelled;
break;
}

View File

@ -338,7 +338,7 @@ ProgressResult ExportOGG::Export(AudacityProject *project,
if ( outFile.Write(page.header, page.header_len).GetLastError() ||
outFile.Write(page.body, page.body_len).GetLastError()) {
// TODO: more precise message
ShowExportErrorDialog("OGG:341");
ShowDiskFullExportErrorDialog();
return ProgressResult::Cancelled;
}