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

An AliasBlockFile that references uncompressed data in an existing file. More...

#include <LegacyAliasBlockFile.h>

Inheritance diagram for LegacyAliasBlockFile:
PCMAliasBlockFile AliasBlockFile BlockFile

Public Member Functions

 LegacyAliasBlockFile (wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, size_t summaryLen, bool noRMS)
 Constructs a LegacyAliasBlockFile, writing the summary to disk. More...
 
virtual ~LegacyAliasBlockFile ()
 
void SaveXML (XMLWriter &xmlFile) override
 Stores a representation of this file in XML. More...
 
BlockFilePtr Copy (wxFileNameWrapper &&fileName) override
 
void Recover () override
 if the on-disk state disappeared, either recover it (if it was More...
 
- Public Member Functions inherited from PCMAliasBlockFile
 PCMAliasBlockFile (wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel)
 Constructs a PCMAliasBlockFile, writing the summary to disk. More...
 
 PCMAliasBlockFile (wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, bool writeSummary)
 Constructs a PCMAliasBlockFile with the option of not writing to disk. More...
 
 PCMAliasBlockFile (wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, float min, float max, float rms)
 
virtual ~PCMAliasBlockFile ()
 
size_t ReadData (samplePtr data, sampleFormat format, size_t start, size_t len, bool mayThrow) const override
 Reads the specified data from the aliased file using libsndfile. More...
 
void SaveXML (XMLWriter &xmlFile) override
 Stores a representation of this file in XML. More...
 
BlockFilePtr Copy (wxFileNameWrapper &&fileName) override
 
void Recover () override
 if the on-disk state disappeared, either recover it (if it was More...
 
- Public Member Functions inherited from AliasBlockFile
 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 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 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 &projDir, const wxChar **attrs)
 
- Static Public Member Functions inherited from PCMAliasBlockFile
static BlockFilePtr BuildFromXML (DirManager &dm, const wxChar **attrs)
 

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 = std::unique_ptr< const BlockFile, ReadUnlocker >
 
- Protected Member Functions inherited from AliasBlockFile
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)
 
- 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 AliasBlockFile
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
 

Detailed Description

An AliasBlockFile that references uncompressed data in an existing file.

Definition at line 18 of file LegacyAliasBlockFile.h.

Constructor & Destructor Documentation

LegacyAliasBlockFile::LegacyAliasBlockFile ( wxFileNameWrapper &&  fileName,
wxFileNameWrapper &&  aliasedFileName,
sampleCount  aliasStart,
size_t  aliasLen,
int  aliasChannel,
size_t  summaryLen,
bool  noRMS 
)

Constructs a LegacyAliasBlockFile, writing the summary to disk.

Definition at line 23 of file LegacyAliasBlockFile.cpp.

30 : PCMAliasBlockFile{ std::move(fileName), std::move(aliasedFileName), aliasStart, aliasLen,
31  aliasChannel, 0.0, 0.0, 0.0 }
32 {
34 
35  if (noRMS)
36  format = int16Sample;
37  else
38  format = floatSample;
39 
41  summaryLen, format,
42  &mSummaryInfo, noRMS, FALSE,
43  &mMin, &mMax, &mRMS);
44 }
wxFileNameWrapper mFileName
Definition: BlockFile.h:235
void ComputeLegacySummaryInfo(const wxFileName &fileName, size_t summaryLen, sampleFormat format, SummaryInfo *info, bool noRMS, bool Silent, float *min, float *max, float *rms)
SummaryInfo mSummaryInfo
Definition: BlockFile.h:237
float mMin
Definition: BlockFile.h:238
int format
Definition: ExportPCM.cpp:56
sampleFormat
Definition: Types.h:188
float mRMS
Definition: BlockFile.h:238
float mMax
Definition: BlockFile.h:238
An AliasBlockFile that references uncompressed data in an existing file.
LegacyAliasBlockFile::~LegacyAliasBlockFile ( )
virtual

Definition at line 46 of file LegacyAliasBlockFile.cpp.

47 {
48 }

Member Function Documentation

BlockFilePtr LegacyAliasBlockFile::BuildFromXML ( const wxString &  projDir,
const wxChar **  attrs 
)
static

Definition at line 86 of file LegacyAliasBlockFile.cpp.

References XMLValueChecker::IsGoodFileName(), XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodInt64(), XMLValueChecker::IsGoodPathName(), XMLValueChecker::IsGoodPathString(), and XMLValueChecker::IsValidChannel().

Referenced by DirManager::HandleXMLTag().

87 {
88  wxFileNameWrapper summaryFileName;
89  wxFileNameWrapper aliasFileName;
90  int aliasStart=0, aliasLen=0, aliasChannel=0;
91  int summaryLen=0;
92  bool noRMS = false;
93  long nValue;
94  long long nnValue;
95 
96  while(*attrs)
97  {
98  const wxChar *attr = *attrs++;
99  const wxChar *value = *attrs++;
100  if (!value)
101  break;
102 
103  const wxString strValue = value;
104  if (!wxStricmp(attr, wxT("name")) && XMLValueChecker::IsGoodFileName(strValue, projDir))
105  //v Should this be
106  // dm.AssignFile(summaryFileName, strValue, false);
107  // as in PCMAliasBlockFile::BuildFromXML? Test with an old project.
108  summaryFileName.Assign(projDir, strValue, wxT(""));
109  else if ( !wxStricmp(attr, wxT("aliaspath")) )
110  {
111  if (XMLValueChecker::IsGoodPathName(strValue))
112  aliasFileName.Assign(strValue);
113  else if (XMLValueChecker::IsGoodFileName(strValue, projDir))
114  // Allow fallback of looking for the file name, located in the data directory.
115  aliasFileName.Assign(projDir, strValue);
116  else if (XMLValueChecker::IsGoodPathString(strValue))
117  // If the aliased file is missing, we failed XMLValueChecker::IsGoodPathName()
118  // and XMLValueChecker::IsGoodFileName, because both do existence tests,
119  // but we want to keep the reference to the missing file because it's a good path string.
120  aliasFileName.Assign(strValue);
121  }
122  else if ( !wxStricmp(attr, wxT("aliasstart")) )
123  {
124  if (XMLValueChecker::IsGoodInt64(strValue) &&
125  strValue.ToLongLong(&nnValue) && (nnValue >= 0))
126  aliasStart = nnValue;
127  }
128  else if (XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
129  { // integer parameters
130  if (!wxStricmp(attr, wxT("aliaslen")) && (nValue >= 0))
131  aliasLen = nValue;
132  else if (!wxStricmp(attr, wxT("aliaschannel")) && XMLValueChecker::IsValidChannel(aliasChannel))
133  aliasChannel = nValue;
134  else if (!wxStricmp(attr, wxT("summarylen")) && (nValue > 0))
135  summaryLen = nValue;
136  else if (!wxStricmp(attr, wxT("norms")))
137  noRMS = (nValue != 0);
138  }
139  }
140 
141  return make_blockfile<LegacyAliasBlockFile>
142  (std::move(summaryFileName), std::move(aliasFileName),
143  aliasStart, aliasLen, aliasChannel, summaryLen, noRMS);
144 }
static bool IsValidChannel(const int nValue)
static bool IsGoodInt64(const wxString &strInt)
Check that the supplied string can be converted to a 64bit integer.
static bool IsGoodPathName(const wxString &strPathName)
static bool IsGoodPathString(const wxString &str)
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
static bool IsGoodFileName(const wxString &strFileName, const wxString &strDirName=wxEmptyString)
BlockFilePtr LegacyAliasBlockFile::Copy ( wxFileNameWrapper &&  newFileName)
overridevirtual

Construct a NEW LegacyAliasBlockFile based on this one, but writing the summary data to a NEW file.

Parameters
newFileNameThe filename to copy the summary data to.

Implements BlockFile.

Definition at line 54 of file LegacyAliasBlockFile.cpp.

References SummaryInfo::fields, AliasBlockFile::mAliasChannel, AliasBlockFile::mAliasedFileName, AliasBlockFile::mAliasStart, BlockFile::mLen, BlockFile::mSummaryInfo, and SummaryInfo::totalSummaryBytes.

55 {
56  auto newBlockFile = make_blockfile<LegacyAliasBlockFile>
57  (std::move(newFileName), wxFileNameWrapper{ mAliasedFileName },
60 
61  return newBlockFile;
62 }
const int mAliasChannel
Definition: BlockFile.h:291
SummaryInfo mSummaryInfo
Definition: BlockFile.h:237
wxFileNameWrapper mAliasedFileName
Definition: BlockFile.h:289
size_t totalSummaryBytes
Definition: BlockFile.h:41
sampleCount mAliasStart
Definition: BlockFile.h:290
size_t mLen
Definition: BlockFile.h:236
int fields
Definition: BlockFile.h:34
void LegacyAliasBlockFile::Recover ( )
overridevirtual

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

Implements BlockFile.

Definition at line 147 of file LegacyAliasBlockFile.cpp.

References AliasBlockFile::WriteSummary().

147  {
148  WriteSummary();
149 }
virtual void WriteSummary()
Write the summary to disk, using the derived ReadData() to get the data.
Definition: BlockFile.cpp:675
void LegacyAliasBlockFile::SaveXML ( XMLWriter xmlFile)
overridevirtual

Stores a representation of this file in XML.

Implements BlockFile.

Definition at line 64 of file LegacyAliasBlockFile.cpp.

References sampleCount::as_long_long(), XMLWriter::EndTag(), SummaryInfo::fields, AliasBlockFile::mAliasChannel, AliasBlockFile::mAliasedFileName, AliasBlockFile::mAliasStart, BlockFile::mFileName, BlockFile::mLen, BlockFile::mSummaryInfo, XMLWriter::StartTag(), SummaryInfo::totalSummaryBytes, and XMLWriter::WriteAttr().

66 {
67  xmlFile.StartTag(wxT("legacyblockfile"));
68 
69  xmlFile.WriteAttr(wxT("alias"), 1);
70  xmlFile.WriteAttr(wxT("name"), mFileName.GetFullName());
71  xmlFile.WriteAttr(wxT("aliaspath"), mAliasedFileName.GetFullPath());
72  xmlFile.WriteAttr(wxT("aliasstart"),
74  xmlFile.WriteAttr(wxT("aliaslen"), mLen);
75  xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
76  xmlFile.WriteAttr(wxT("summarylen"), mSummaryInfo.totalSummaryBytes);
77  if (mSummaryInfo.fields < 3)
78  xmlFile.WriteAttr(wxT("norms"), 1);
79 
80  xmlFile.EndTag(wxT("legacyblockfile"));
81 }
const int mAliasChannel
Definition: BlockFile.h:291
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:78
wxFileNameWrapper mFileName
Definition: BlockFile.h:235
virtual void WriteAttr(const wxString &name, const wxString &value)
Definition: XMLWriter.cpp:131
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:101
SummaryInfo mSummaryInfo
Definition: BlockFile.h:237
wxFileNameWrapper mAliasedFileName
Definition: BlockFile.h:289
size_t totalSummaryBytes
Definition: BlockFile.h:41
sampleCount mAliasStart
Definition: BlockFile.h:290
size_t mLen
Definition: BlockFile.h:236
int fields
Definition: BlockFile.h:34
long long as_long_long() const
Definition: Types.h:90

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