/// Read the summary of this alias block from disk.  Since the audio data
/// is elsewhere, this consists of reading the entire summary file.
///
/// @param *data The buffer where the summary data will be stored.  It must
///              be at least mSummaryInfo.totalSummaryBytes long.
bool ODPCMAliasBlockFile::ReadSummary(void *data)
{
   
   mFileNameMutex.Lock();
   wxFFile summaryFile(mFileName.GetFullPath(), wxT("rb"));
   
   if( !summaryFile.IsOpened() ){

      // new model; we need to return valid data
      memset(data,0,(size_t)mSummaryInfo.totalSummaryBytes);
   
      // we silence the logging for this operation in this object
      // after first occurrence of error; it's already reported and
      // spewing at the user will complicate the user's ability to
      // deal
      mSilentLog=TRUE;
      
      mFileNameMutex.Unlock();
      return true;

   }else mSilentLog=FALSE; // worked properly, any future error is new 

   int read = summaryFile.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);

   FixSummary(data);

   
   mFileNameMutex.Unlock();
   return (read == mSummaryInfo.totalSummaryBytes);
}
/// Read the summary of this alias block from disk.  Since the audio data
/// is elsewhere, this consists of reading the entire summary file.
/// Fill with zeroes and return false if data are unavailable for any reason.
///
/// @param *data The buffer where the summary data will be stored.  It must
///              be at least mSummaryInfo.totalSummaryBytes long.
bool ODPCMAliasBlockFile::ReadSummary(ArrayOf<char> &data)
{
   data.reinit( mSummaryInfo.totalSummaryBytes );

   ODLocker locker{ &mFileNameMutex };
   wxFFile summaryFile(mFileName.GetFullPath(), wxT("rb"));

   if( !summaryFile.IsOpened() ) {

      // NEW model; we need to return valid data
      memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);

      // we silence the logging for this operation in this object
      // after first occurrence of error; it's already reported and
      // spewing at the user will complicate the user's ability to
      // deal
      mSilentLog = TRUE;

      return false;
   }
   else
      mSilentLog = FALSE; // worked properly, any future error is NEW

   auto read = summaryFile.Read(data.get(), mSummaryInfo.totalSummaryBytes);

   if (read != mSummaryInfo.totalSummaryBytes) {
      memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
      return false;
   }
   
   FixSummary(data.get());

   return true;
}
Beispiel #3
0
/// Read the summary section of the disk file.
///
/// @param *data The buffer to write the data to.  It must be at least
/// mSummaryinfo.totalSummaryBytes long.
bool SimpleBlockFile::ReadSummary(void *data)
{
   if (mCache.active)
   {
      //wxLogDebug("SimpleBlockFile::ReadSummary(): Summary is already in cache.");
      memcpy(data, mCache.summaryData, (size_t)mSummaryInfo.totalSummaryBytes);
      return true;
   } else
   {
      //wxLogDebug("SimpleBlockFile::ReadSummary(): Reading summary from disk.");

      wxFFile file(mFileName.GetFullPath(), wxT("rb"));

      {
         Maybe<wxLogNull> silence{};
         if (mSilentLog)
            silence.create();

         if (!file.IsOpened()){

            memset(data, 0, (size_t)mSummaryInfo.totalSummaryBytes);

            mSilentLog = TRUE;

            return true;

         }
      }
      mSilentLog=FALSE;

      // The offset is just past the au header
      if( !file.Seek(sizeof(auHeader)) )
         return false;

      int read = (int)file.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);

      FixSummary(data);

      return (read == mSummaryInfo.totalSummaryBytes);
   }
}
/// Read the summary section of the disk file.
///
/// @param *data The buffer to write the data to.  It must be at least
/// mSummaryinfo.totalSummaryBytes long.
bool SimpleBlockFile::ReadSummary(void *data)
{
   if (mCache.active)
   {
      DEBUG_OUTPUT("ReadSummary: Summary is already in cache");
      memcpy(data, mCache.summaryData, (size_t)mSummaryInfo.totalSummaryBytes);
      return true;
   } else
   {
      DEBUG_OUTPUT("ReadSummary: Reading summary from disk");
      
      wxFFile file(mFileName.GetFullPath(), wxT("rb"));

      wxLogNull *silence=0;
      if(mSilentLog)silence= new wxLogNull();
   
      if(!file.IsOpened() ){
      
         memset(data,0,(size_t)mSummaryInfo.totalSummaryBytes);

         if(silence) delete silence;
         mSilentLog=TRUE;

         return true;
      
      }

      if(silence) delete silence;
      mSilentLog=FALSE;
   
      // The offset is just past the au header
      if( !file.Seek(sizeof(auHeader)) )
         return false;
   
      int read = (int)file.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);

      FixSummary(data);

      return (read == mSummaryInfo.totalSummaryBytes);
   }
}