1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-04-01 20:14:49 +02:00

Zero and return false for all failures to read block file summary...

... Though in the only place where these summaries are used, which is
Sequence::GetWaveDisplay, we ignore the correctly reported error code anyway.

Also RAII in management of relevant memory buffers and mutexes.
This commit is contained in:
Paul Licameli
2016-12-22 12:30:07 -05:00
parent 7b7ad75a49
commit 2677796b0c
13 changed files with 140 additions and 110 deletions

View File

@@ -151,11 +151,13 @@ LegacyBlockFile::~LegacyBlockFile()
}
/// Read the summary section of the disk file.
/// Fill with zeroes and return false if data are unavailable for any reason.
///
/// @param *data The buffer to write the data to. It must be at least
/// mSummaryinfo.totalSummaryBytes long.
bool LegacyBlockFile::ReadSummary(void *data)
bool LegacyBlockFile::ReadSummary(ArrayOf<char> &data)
{
data.reinit( mSummaryInfo.totalSummaryBytes );
wxFFile summaryFile(mFileName.GetFullPath(), wxT("rb"));
size_t read;
{
@@ -163,20 +165,25 @@ bool LegacyBlockFile::ReadSummary(void *data)
if (mSilentLog)
silence.create();
if (!summaryFile.IsOpened()){
if (!summaryFile.IsOpened()) {
memset(data, 0, mSummaryInfo.totalSummaryBytes);
memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
mSilentLog = TRUE;
return true;
return false;
}
read = summaryFile.Read(data, mSummaryInfo.totalSummaryBytes);
read = summaryFile.Read(data.get(), mSummaryInfo.totalSummaryBytes);
}
mSilentLog=FALSE;
mSilentLog = FALSE;
return (read == mSummaryInfo.totalSummaryBytes);
if (read != mSummaryInfo.totalSummaryBytes) {
memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
return false;
}
return true;
}
/// Read the data portion of the block file using libsndfile. Convert it