1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

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.

This commit is contained in:
richardash1981 2010-02-20 22:20:26 +00:00
parent 1a1f431584
commit 68f7665a70

View File

@ -529,6 +529,7 @@ int ExportPCM::Export(AudacityProject *project,
formatStr.c_str())); formatStr.c_str()));
while(updateResult == eProgressSuccess) { while(updateResult == eProgressSuccess) {
sampleCount samplesWritten;
sampleCount numSamples = mixer->Process(maxBlockLen); sampleCount numSamples = mixer->Process(maxBlockLen);
if (numSamples == 0) if (numSamples == 0)
@ -538,11 +539,21 @@ int ExportPCM::Export(AudacityProject *project,
ODManager::LockLibSndFileMutex(); ODManager::LockLibSndFileMutex();
if (format == int16Sample) if (format == int16Sample)
sf_writef_short(sf, (short *)mixed, numSamples); samplesWritten = sf_writef_short(sf, (short *)mixed, numSamples);
else else
sf_writef_float(sf, (float *)mixed, numSamples); samplesWritten = sf_writef_float(sf, (float *)mixed, numSamples);
ODManager::UnlockLibSndFileMutex(); 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); updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
} }