mirror of
				https://github.com/cookiengineer/audacity
				synced 2025-11-04 08:04:06 +01:00 
			
		
		
		
	Fix for bug #996
This commit is contained in:
		@@ -137,6 +137,9 @@ SimpleBlockFile::SimpleBlockFile(wxFileName existingFile, sampleCount len,
 | 
			
		||||
                                 float min, float max, float rms):
 | 
			
		||||
   BlockFile(existingFile, len)
 | 
			
		||||
{
 | 
			
		||||
   // Set an invalid format to force GetSpaceUsage() to read it from the file.
 | 
			
		||||
   mFormat = (sampleFormat) 0;
 | 
			
		||||
 | 
			
		||||
   mMin = min;
 | 
			
		||||
   mMax = max;
 | 
			
		||||
   mRMS = rms;
 | 
			
		||||
@@ -543,10 +546,54 @@ wxLongLong SimpleBlockFile::GetSpaceUsage()
 | 
			
		||||
   {
 | 
			
		||||
      // We don't know space usage yet
 | 
			
		||||
      return 0;
 | 
			
		||||
   } else
 | 
			
		||||
   {
 | 
			
		||||
      return sizeof(auHeader) + mSummaryInfo.totalSummaryBytes + (GetLength() * SAMPLE_SIZE(mFormat));
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   // Don't know the format, so it must be read from the file
 | 
			
		||||
   if (mFormat == (sampleFormat) 0)
 | 
			
		||||
   {
 | 
			
		||||
      // Check sample format
 | 
			
		||||
      wxFFile file(mFileName.GetFullPath(), wxT("rb"));
 | 
			
		||||
      if (!file.IsOpened())
 | 
			
		||||
      {
 | 
			
		||||
         // Don't read into cache if file not available
 | 
			
		||||
         return 0;
 | 
			
		||||
      }
 | 
			
		||||
   
 | 
			
		||||
      auHeader header;
 | 
			
		||||
   
 | 
			
		||||
      if (file.Read(&header, sizeof(header)) != sizeof(header))
 | 
			
		||||
      {
 | 
			
		||||
         // Corrupt file
 | 
			
		||||
         return 0;
 | 
			
		||||
      }
 | 
			
		||||
   
 | 
			
		||||
      wxUint32 encoding;
 | 
			
		||||
   
 | 
			
		||||
      if (header.magic == 0x2e736e64)
 | 
			
		||||
         encoding = header.encoding; // correct endianness
 | 
			
		||||
      else
 | 
			
		||||
         encoding = SwapUintEndianess(header.encoding);
 | 
			
		||||
   
 | 
			
		||||
      switch (encoding)
 | 
			
		||||
      {
 | 
			
		||||
      case AU_SAMPLE_FORMAT_16:
 | 
			
		||||
         mFormat = int16Sample;
 | 
			
		||||
         break;
 | 
			
		||||
      case AU_SAMPLE_FORMAT_24:
 | 
			
		||||
         mFormat = int24Sample;
 | 
			
		||||
         break;
 | 
			
		||||
      default:
 | 
			
		||||
         // floatSample is a safe default (we will never loose data)
 | 
			
		||||
         mFormat = floatSample;
 | 
			
		||||
         break;
 | 
			
		||||
      }
 | 
			
		||||
   
 | 
			
		||||
      file.Close();
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   return sizeof(auHeader) + 
 | 
			
		||||
          mSummaryInfo.totalSummaryBytes +
 | 
			
		||||
          (GetLength() * SAMPLE_SIZE_DISK(mFormat));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SimpleBlockFile::Recover(){
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user