Audacity  2.2.2
Public Member Functions | Static Public Member Functions | List of all members
SilentBlockFile Class Referencefinal

A BlockFile containing nothing but silence. Saves disk space. More...

#include <SilentBlockFile.h>

Inheritance diagram for SilentBlockFile:
BlockFile

Public Member Functions

 SilentBlockFile (size_t sampleLen)
 
virtual ~SilentBlockFile ()
 
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 (DirManager &dm, const wxChar **attrs)
 static More...
 

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)
 
- Protected Attributes inherited from BlockFile
wxFileNameWrapper mFileName
 
size_t mLen
 
SummaryInfo mSummaryInfo
 
float mMin
 
float mMax
 
float mRMS
 
bool mSilentLog
 

Detailed Description

A BlockFile containing nothing but silence. Saves disk space.

Definition at line 24 of file SilentBlockFile.h.

Constructor & Destructor Documentation

SilentBlockFile::SilentBlockFile ( size_t  sampleLen)

Definition at line 15 of file SilentBlockFile.cpp.

15  :
16 BlockFile{ wxFileNameWrapper{}, sampleLen }
17 {
18  mMin = 0.;
19  mMax = 0.;
20  mRMS = 0.;
21 }
A BlockFile is a chunk of immutable audio data.
Definition: BlockFile.h:56
float mMin
Definition: BlockFile.h:246
float mRMS
Definition: BlockFile.h:246
float mMax
Definition: BlockFile.h:246
SilentBlockFile::~SilentBlockFile ( )
virtual

Definition at line 23 of file SilentBlockFile.cpp.

24 {
25 }

Member Function Documentation

BlockFilePtr SilentBlockFile::BuildFromXML ( DirManager dm,
const wxChar **  attrs 
)
static

static

Definition at line 56 of file SilentBlockFile.cpp.

References XMLValueChecker::IsGoodInt().

Referenced by DirManager::HandleXMLTag().

57 {
58  long nValue;
59  size_t len = 0;
60 
61  while(*attrs)
62  {
63  const wxChar *attr = *attrs++;
64  const wxChar *value = *attrs++;
65  if (!value)
66  break;
67 
68  const wxString strValue = value;
69  if (!wxStrcmp(attr, wxT("len")) &&
70  XMLValueChecker::IsGoodInt(strValue) &&
71  strValue.ToLong(&nValue) &&
72  nValue > 0)
73  len = nValue;
74  }
75 
76  return make_blockfile<SilentBlockFile>(len);
77 }
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
BlockFilePtr SilentBlockFile::Copy ( wxFileNameWrapper &&  newFileName)
overridevirtual

Create a NEW block file identical to this one.

Create a copy of this BlockFile.

Implements BlockFile.

Definition at line 80 of file SilentBlockFile.cpp.

References BlockFile::mLen.

81 {
82  auto newBlockFile = make_blockfile<SilentBlockFile>(mLen);
83 
84  return newBlockFile;
85 }
size_t mLen
Definition: BlockFile.h:244
auto SilentBlockFile::GetSpaceUsage ( ) const
overridevirtual

Implements BlockFile.

Definition at line 87 of file SilentBlockFile.cpp.

88 {
89  return 0;
90 }
size_t SilentBlockFile::ReadData ( samplePtr  data,
sampleFormat  format,
size_t  start,
size_t  len,
bool  mayThrow 
) const
overridevirtual

Read the data section of the disk file.

Implements BlockFile.

Definition at line 34 of file SilentBlockFile.cpp.

References ClearSamples().

36 {
37  ClearSamples(data, format, 0, len);
38 
39  return len;
40 }
int format
Definition: ExportPCM.cpp:56
void ClearSamples(samplePtr dst, sampleFormat format, size_t start, size_t len)
bool SilentBlockFile::ReadSummary ( ArrayOf< char > &  data)
overridevirtual

Read the summary section of the disk file.

Implements BlockFile.

Definition at line 27 of file SilentBlockFile.cpp.

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

28 {
30  memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
31  return true;
32 }
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:499
SummaryInfo mSummaryInfo
Definition: BlockFile.h:245
size_t totalSummaryBytes
Definition: BlockFile.h:41
void SilentBlockFile::Recover ( )
inlineoverridevirtual

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

Implements BlockFile.

Definition at line 46 of file SilentBlockFile.h.

46 { };
void SilentBlockFile::SaveXML ( XMLWriter xmlFile)
overridevirtual

Write an XML representation of this file.

Implements BlockFile.

Definition at line 42 of file SilentBlockFile.cpp.

References XMLWriter::EndTag(), BlockFile::mLen, XMLWriter::StartTag(), and XMLWriter::WriteAttr().

44 {
45  xmlFile.StartTag(wxT("silentblockfile"));
46 
47  xmlFile.WriteAttr(wxT("len"), mLen);
48 
49  xmlFile.EndTag(wxT("silentblockfile"));
50 }
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:78
virtual void WriteAttr(const wxString &name, const wxString &value)
Definition: XMLWriter.cpp:131
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:101
size_t mLen
Definition: BlockFile.h:244

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