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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user