Audacity  2.2.0
AliasBlockFile Class Reference

A BlockFile that refers to data in an existing file. More...

#include <BlockFile.h>

Inheritance diagram for AliasBlockFile:
BlockFile PCMAliasBlockFile LegacyAliasBlockFile ODPCMAliasBlockFile

Public Member Functions

 AliasBlockFile (wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel)
 Constructs an AliasBlockFile. More...
 
 AliasBlockFile (wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, float min, float max, float RMS)
 
virtual ~AliasBlockFile ()
 
DiskByteCount GetSpaceUsage () const override
 
void SilenceAliasLog () const
 as SilentLog (which would affect Summary data access), but More...
 
const wxFileName & GetAliasedFileName () const
 
void ChangeAliasedFileName (wxFileNameWrapper &&newAliasedFile)
 
bool IsAlias () const override
 Returns TRUE if this block references another disk file. More...
 
- Public Member Functions inherited from BlockFile
 BlockFile (wxFileNameWrapper &&fileName, size_t samples)
 Construct a BlockFile. More...
 
virtual ~BlockFile ()
 
virtual size_t ReadData (samplePtr data, sampleFormat format, size_t start, size_t len, bool mayThrow=true) const =0
 
virtual bool GetNeedWriteCacheToDisk ()
 
virtual void WriteCacheToDisk ()
 
virtual bool GetNeedFillCache ()
 
virtual void FillCache ()
 
virtual void SaveXML (XMLWriter &xmlFile)=0
 Stores a representation of this file in XML. More...
 
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 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...
 
virtual BlockFilePtr Copy (wxFileNameWrapper &&newFileName)=0
 Create a NEW BlockFile identical to this, using the given filename. More...
 
virtual void Recover ()=0
 if the on-disk state disappeared, either recover it (if it was More...
 
void SilenceLog () const
 if we've detected an on-disk problem, the user opted to More...
 
virtual void CloseLock ()
 
ReadLock LockForRead () const
 

Protected Member Functions

virtual void WriteSummary ()
 Write the summary to disk, using the derived ReadData() to get the data. More...
 
bool ReadSummary (ArrayOf< char > &data) override
 Read the summary into a buffer. More...
 
- 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)
 

Protected Attributes

wxFileNameWrapper mAliasedFileName
 
sampleCount mAliasStart
 
const int mAliasChannel
 
bool mSilentAliasLog
 
- 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 >
 
- 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

A BlockFile that refers to data in an existing file.

An AliasBlockFile references an existing disk file for its storage instead of copying the data. It still writes a file to disk, but only stores summary data in it.

This is a common base class for all alias block files. It handles reading and writing summary data, leaving very little for derived classes to need to implement.

Constructor & Destructor Documentation

AliasBlockFile::AliasBlockFile ( wxFileNameWrapper &&  baseFileName,
wxFileNameWrapper &&  aliasedFileName,
sampleCount  aliasStart,
size_t  aliasLen,
int  aliasChannel 
)

Constructs an AliasBlockFile.

Constructs an AliasBlockFile based on the given information about the aliased file.

Note that derived classes /must/ call AliasBlockFile::WriteSummary() in their constructors for the summary file to be correctly written to disk.

Parameters
baseFileNameThe name of the summary file to be written, but without an extension. This constructor will add the appropriate extension before passing it to BlockFile::BlockFile
aliasedFileNameThe name of the file where the audio data for this block actually exists.
aliasStartThe offset in the aliased file where this block's data begins
aliasLenThe length of this block's data in the aliased file.
aliasChannelThe channel where this block's data is located in the aliased file

References mAliasChannel, mAliasedFileName, mAliasStart, and mSilentAliasLog.

AliasBlockFile::AliasBlockFile ( wxFileNameWrapper &&  existingSummaryFileName,
wxFileNameWrapper &&  aliasedFileName,
sampleCount  aliasStart,
size_t  aliasLen,
int  aliasChannel,
float  min,
float  max,
float  RMS 
)
AliasBlockFile::~AliasBlockFile ( )
virtual

Member Function Documentation

void AliasBlockFile::ChangeAliasedFileName ( wxFileNameWrapper &&  newAliasedFile)

Modify this block to point at a different file. This is generally looked down on, but it is necessary in one case: see DirManager::EnsureSafeFilename().

References mAliasedFileName.

const wxFileName& AliasBlockFile::GetAliasedFileName ( ) const
inline
auto AliasBlockFile::GetSpaceUsage ( ) const
overridevirtual

Implements BlockFile.

References BlockFile::mFileName.

bool AliasBlockFile::IsAlias ( ) const
inlineoverridevirtual

Returns TRUE if this block references another disk file.

Reimplemented from BlockFile.

bool AliasBlockFile::ReadSummary ( ArrayOf< char > &  data)
overrideprotectedvirtual

Read the summary into a buffer.

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.

Parameters
*dataThe buffer where the summary data will be stored. It must be at least mSummaryInfo.totalSummaryBytes long.

Implements BlockFile.

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

void AliasBlockFile::SilenceAliasLog ( ) const
inline

as SilentLog (which would affect Summary data access), but

References mSilentAliasLog.

void AliasBlockFile::WriteSummary ( )
protectedvirtual

Write the summary to disk, using the derived ReadData() to get the data.

Write the summary to disk. Derived classes must call this method from their constructors for the summary to be correctly written. It uses the derived class's ReadData() to retrieve the data to summarize.

Reimplemented in ODPCMAliasBlockFile.

References BlockFile::CalcSummary(), BlockFile::mFileName, BlockFile::mLen, BlockFile::mSummaryInfo, SampleBuffer::ptr(), BlockFile::ReadData(), and SummaryInfo::totalSummaryBytes.

Referenced by LegacyAliasBlockFile::Recover(), and PCMAliasBlockFile::Recover().

Member Data Documentation

bool AliasBlockFile::mSilentAliasLog
mutableprotected

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