From 68f7665a70b3938521d576e388e38be57dd3ee58 Mon Sep 17 00:00:00 2001 From: richardash1981 Date: Sat, 20 Feb 2010 22:20:26 +0000 Subject: [PATCH] Commit an improved version of patch by Benjamin Drung to check if data is sucessfully being exported or not when saving files through libsndfile, and warn the user if the export fails. --- src/export/ExportPCM.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index f898fc308..ddba0221a 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -529,6 +529,7 @@ int ExportPCM::Export(AudacityProject *project, formatStr.c_str())); while(updateResult == eProgressSuccess) { + sampleCount samplesWritten; sampleCount numSamples = mixer->Process(maxBlockLen); if (numSamples == 0) @@ -538,11 +539,21 @@ int ExportPCM::Export(AudacityProject *project, ODManager::LockLibSndFileMutex(); if (format == int16Sample) - sf_writef_short(sf, (short *)mixed, numSamples); + samplesWritten = sf_writef_short(sf, (short *)mixed, numSamples); else - sf_writef_float(sf, (float *)mixed, numSamples); + samplesWritten = sf_writef_float(sf, (float *)mixed, numSamples); ODManager::UnlockLibSndFileMutex(); + if (samplesWritten != numSamples) { + char buffer2[1000]; + sf_error_str(sf, buffer2, 1000); + wxMessageBox(wxString::Format( + _("Error while writing %s file (disk full?).\nLibsndfile says \"%s\""), + formatStr.c_str(), + wxString::FromAscii(buffer2).c_str())); + break; + } + updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0); }