Audacity  3.0.3
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:
[legend]
Collaboration diagram for SilentBlockFile:
[legend]

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
 

Static Public Member Functions

static BlockFilePtr BuildFromXML (DirManager &dm, const wxChar **attrs)
 static More...
 

Detailed Description

A BlockFile containing nothing but silence. Saves disk space.

Definition at line 22 of file SilentBlockFile.h.

Constructor & Destructor Documentation

◆ SilentBlockFile()

SilentBlockFile::SilentBlockFile ( size_t  sampleLen)

Definition at line 18 of file SilentBlockFile.cpp.

18  :
19 BlockFile{ wxFileNameWrapper{}, sampleLen }
20 {
21  mMin = 0.;
22  mMax = 0.;
23  mRMS = 0.;
24 }

◆ ~SilentBlockFile()

SilentBlockFile::~SilentBlockFile ( )
virtual

Definition at line 26 of file SilentBlockFile.cpp.

27 {
28 }

Member Function Documentation

◆ BuildFromXML()

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

static

Definition at line 59 of file SilentBlockFile.cpp.

60 {
61  long nValue;
62  size_t len = 0;
63 
64  while(*attrs)
65  {
66  const wxChar *attr = *attrs++;
67  const wxChar *value = *attrs++;
68  if (!value)
69  break;
70 
71  const wxString strValue = value;
72  if (!wxStrcmp(attr, wxT("len")) &&
73  XMLValueChecker::IsGoodInt(strValue) &&
74  strValue.ToLong(&nValue) &&
75  nValue > 0)
76  len = nValue;
77  }
78 
79  return make_blockfile<SilentBlockFile>(len);
80 }

References XMLValueChecker::IsGoodInt().

Here is the call graph for this function:

◆ Copy()

BlockFilePtr SilentBlockFile::Copy ( wxFileNameWrapper &&  newFileName)
override

Create a NEW block file identical to this one.

Create a copy of this BlockFile.

Definition at line 83 of file SilentBlockFile.cpp.

84 {
85  auto newBlockFile = make_blockfile<SilentBlockFile>(mLen);
86 
87  return newBlockFile;
88 }

◆ GetSpaceUsage()

auto SilentBlockFile::GetSpaceUsage ( ) const
override

Definition at line 90 of file SilentBlockFile.cpp.

91 {
92  return 0;
93 }

◆ ReadData()

size_t SilentBlockFile::ReadData ( samplePtr  data,
sampleFormat  format,
size_t  start,
size_t  len,
bool  mayThrow 
) const
override

Read the data section of the disk file.

Definition at line 37 of file SilentBlockFile.cpp.

39 {
40  ClearSamples(data, format, 0, len);
41 
42  return len;
43 }

References ClearSamples(), and format.

Here is the call graph for this function:

◆ ReadSummary()

bool SilentBlockFile::ReadSummary ( ArrayOf< char > &  data)
override

Read the summary section of the disk file.

Definition at line 30 of file SilentBlockFile.cpp.

31 {
32  data.reinit( mSummaryInfo.totalSummaryBytes );
33  memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
34  return true;
35 }

References ArrayOf< X >::reinit().

Here is the call graph for this function:

◆ Recover()

void SilentBlockFile::Recover ( void  )
inlineoverride

Definition at line 44 of file SilentBlockFile.h.

44 { };

◆ SaveXML()

void SilentBlockFile::SaveXML ( XMLWriter xmlFile)
override

Write an XML representation of this file.

Definition at line 45 of file SilentBlockFile.cpp.

47 {
48  xmlFile.StartTag(wxT("silentblockfile"));
49 
50  xmlFile.WriteAttr(wxT("len"), mLen);
51 
52  xmlFile.EndTag(wxT("silentblockfile"));
53 }

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

Here is the call graph for this function:

The documentation for this class was generated from the following files:
XMLWriter::EndTag
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:99
ClearSamples
void ClearSamples(samplePtr dst, sampleFormat format, size_t start, size_t len)
Definition: SampleFormat.cpp:77
wxFileNameWrapper
Definition: wxFileNameWrapper.h:21
XMLValueChecker::IsGoodInt
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
Definition: XMLTagHandler.cpp:157
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
format
int format
Definition: ExportPCM.cpp:56
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:76