Audacity  2.2.0
LegacyBlockFile Class Referencefinal

Audacity 1.1.0 block file format: More...

#include <LegacyBlockFile.h>

Inheritance diagram for LegacyBlockFile:
BlockFile

Public Member Functions

 LegacyBlockFile (wxFileNameWrapper &&existingFile, sampleFormat format, size_t summaryLen, size_t len, bool noRMS)
 Create the memory structure to refer to the given block file. More...
 
virtual ~LegacyBlockFile ()
 
bool ReadSummary (ArrayOf< char > &data) override
 Read the summary section of the disk file. More...
 
size_t ReadData (samplePtr data, sampleFormat format, size_t start, size_t len, bool mayThrow) const override
 Read the data section of the disk file. More...
 
BlockFilePtr Copy (wxFileNameWrapper &&newFileName) override
 Create a NEW block file identical to this one. More...
 
void SaveXML (XMLWriter &xmlFile) override
 Write an XML representation of this file. More...
 
DiskByteCount GetSpaceUsage () const override
 
void Recover () override
 if the on-disk state disappeared, either recover it (if it was More...
 
- Public Member Functions inherited from BlockFile
 BlockFile (wxFileNameWrapper &&fileName, size_t samples)
 Construct a BlockFile. More...
 
virtual ~BlockFile ()
 
virtual bool GetNeedWriteCacheToDisk ()
 
virtual void WriteCacheToDisk ()
 
virtual bool GetNeedFillCache ()
 
virtual void FillCache ()
 
virtual GetFileNameResult GetFileName () const
 
virtual void SetFileName (wxFileNameWrapper &&name)
 sets the file name the summary info will be saved in. threadsafe. More...
 
size_t GetLength () const
 
void SetLength (size_t newLen)
 
virtual void Lock ()
 Locks this BlockFile, to prevent it from being moved. More...
 
virtual void Unlock ()
 Unlock this BlockFile, allowing it to be moved. More...
 
virtual bool IsLocked ()
 Returns TRUE if this BlockFile is locked. More...
 
virtual MinMaxRMS GetMinMaxRMS (size_t start, size_t len, bool mayThrow=true) const
 Gets extreme values for the specified region. More...
 
virtual MinMaxRMS GetMinMaxRMS (bool mayThrow=true) const
 Gets extreme values for the entire block. More...
 
virtual bool Read256 (float *buffer, size_t start, size_t len)
 Returns the 256 byte summary data block. More...
 
virtual bool Read64K (float *buffer, size_t start, size_t len)
 Returns the 64K summary data block. More...
 
virtual bool IsAlias () const
 Returns TRUE if this block references another disk file. More...
 
virtual bool IsSummaryAvailable () const
 Returns TRUE if this block's complete summary has been computed and is ready (for OD) More...
 
virtual bool IsDataAvailable () const
 Returns TRUE if this block's complete data is ready to be accessed by Read() More...
 
virtual bool IsSummaryBeingComputed ()
 Returns TRUE if the summary has not yet been written, but is actively being computed and written to disk. More...
 
void SilenceLog () const
 if we've detected an on-disk problem, the user opted to More...
 
virtual void CloseLock ()
 
ReadLock LockForRead () const
 

Static Public Member Functions

static BlockFilePtr BuildFromXML (const wxString &dir, const wxChar **attrs, size_t len, sampleFormat format)
 static More...
 

Protected Attributes

sampleFormat mFormat
 
- Protected Attributes inherited from BlockFile
wxFileNameWrapper mFileName
 
size_t mLen
 
SummaryInfo mSummaryInfo
 
float mMin
 
float mMax
 
float mRMS
 
bool mSilentLog
 

Additional Inherited Members

- Public Types inherited from BlockFile
using DiskByteCount = unsigned long long
 
- Static Public Attributes inherited from BlockFile
static unsigned long gBlockFileDestructionCount { 0 }
 
- Protected Types inherited from BlockFile
using ReadLockBase = movable_ptr_with_deleter< const BlockFile, ReadUnlocker >
 
- Protected Member Functions inherited from BlockFile
virtual void LockRead () const
 Prevents a read on other threads. The basic blockfile runs on only one thread, so does nothing. More...
 
virtual void UnlockRead () const
 Allows reading on other threads. More...
 
virtual void * CalcSummary (samplePtr buffer, size_t len, sampleFormat format, ArrayOf< char > &cleanup)
 
void CalcSummaryFromBuffer (const float *fbuffer, size_t len, float *summary256, float *summary64K)
 
virtual void FixSummary (void *data)
 
- Static Protected Member Functions inherited from BlockFile
static size_t CommonReadData (bool mayThrow, const wxFileName &fileName, bool &mSilentLog, const AliasBlockFile *pAliasFile, sampleCount origin, unsigned channel, samplePtr data, sampleFormat format, size_t start, size_t len, const sampleFormat *pLegacyFormat=nullptr, size_t legacyLen=0)
 

Detailed Description

Audacity 1.1.0 block file format:

  • Header tag: 20 bytes "AudacityBlockFile110"
  • 64K summaries (min, max, RMS, each a 4-byte float)
  • 256 summaries (min, max, RMS, each a 4-byte float)

Constructor & Destructor Documentation

LegacyBlockFile::LegacyBlockFile ( wxFileNameWrapper &&  existingFile,
sampleFormat  format,
size_t  summaryLen,
size_t  len,
bool  noRMS 
)

Create the memory structure to refer to the given block file.

Construct a LegacyBlockFile memory structure that will point to an existing block file. This file must exist and be a valid block file.

Parameters
existingFileThe disk file this LegacyBlockFile should use.
LegacyBlockFile::~LegacyBlockFile ( )
virtual

Member Function Documentation

BlockFilePtr LegacyBlockFile::BuildFromXML ( const wxString &  dir,
const wxChar **  attrs,
size_t  len,
sampleFormat  format 
)
static
BlockFilePtr LegacyBlockFile::Copy ( wxFileNameWrapper &&  newFileName)
overridevirtual

Create a NEW block file identical to this one.

Create a copy of this BlockFile, but using a different disk file.

Parameters
newFileNameThe name of the NEW file to use.

Implements BlockFile.

References SummaryInfo::fields, mFormat, BlockFile::mLen, BlockFile::mSummaryInfo, and SummaryInfo::totalSummaryBytes.

auto LegacyBlockFile::GetSpaceUsage ( ) const
overridevirtual

Implements BlockFile.

References BlockFile::mFileName.

size_t LegacyBlockFile::ReadData ( samplePtr  data,
sampleFormat  format,
size_t  start,
size_t  len,
bool  mayThrow 
) const
overridevirtual

Read the data section of the disk file.

Read the data portion of the block file using libsndfile. Convert it to the given format if it is not already.

Parameters
dataThe buffer where the data will be stored
formatThe format the data will be stored in
startThe offset in this block file
lenThe number of samples to read

Implements BlockFile.

References BlockFile::CommonReadData(), BlockFile::mFileName, mFormat, BlockFile::mLen, BlockFile::mSilentLog, BlockFile::mSummaryInfo, and SummaryInfo::totalSummaryBytes.

bool LegacyBlockFile::ReadSummary ( ArrayOf< char > &  data)
overridevirtual

Read the summary section of the disk file.

Read the summary section of the disk file. Fill with zeroes and return false if data are unavailable for any reason.

Parameters
*dataThe buffer to write the data to. It must be at least mSummaryinfo.totalSummaryBytes long.

Implements BlockFile.

References Maybe< X >::create(), BlockFile::mFileName, BlockFile::mSilentLog, BlockFile::mSummaryInfo, ArrayOf< X >::reinit(), and SummaryInfo::totalSummaryBytes.

void LegacyBlockFile::Recover ( )
overridevirtual

if the on-disk state disappeared, either recover it (if it was

Implements BlockFile.

void LegacyBlockFile::SaveXML ( XMLWriter xmlFile)
overridevirtual

Member Data Documentation

sampleFormat LegacyBlockFile::mFormat
protected

Referenced by Copy(), and ReadData().


The documentation for this class was generated from the following files: