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

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
 
BlockFilePtr Copy (wxFileNameWrapper &&fileName) override
 
void Recover () override
 
- 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
 
BlockFilePtr Copy (wxFileNameWrapper &&fileName) override
 
void Recover () override
 

Static Public Member Functions

static BlockFilePtr BuildFromXML (const FilePath &projDir, const wxChar **attrs)
 
- Static Public Member Functions inherited from PCMAliasBlockFile
static BlockFilePtr BuildFromXML (DirManager &dm, const wxChar **attrs)
 

Detailed Description

An AliasBlockFile that references uncompressed data in an existing file.

Definition at line 17 of file LegacyAliasBlockFile.h.

Constructor & Destructor Documentation

◆ LegacyAliasBlockFile()

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 24 of file LegacyAliasBlockFile.cpp.

31 : PCMAliasBlockFile{ std::move(fileName), std::move(aliasedFileName), aliasStart, aliasLen,
32  aliasChannel, 0.0, 0.0, 0.0 }
33 {
35 
36  if (noRMS)
38  else
40 
41  ComputeLegacySummaryInfo(mFileName,
42  summaryLen, format,
43  &mSummaryInfo, noRMS, FALSE,
44  &mMin, &mMax, &mRMS);
45 }

◆ ~LegacyAliasBlockFile()

LegacyAliasBlockFile::~LegacyAliasBlockFile ( )
virtual

Definition at line 47 of file LegacyAliasBlockFile.cpp.

48 {
49 }

Member Function Documentation

◆ BuildFromXML()

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

Definition at line 87 of file LegacyAliasBlockFile.cpp.

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

References XMLValueChecker::IsGoodFileName(), XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodInt64(), XMLValueChecker::IsGoodPathName(), XMLValueChecker::IsGoodPathString(), and anonymous_namespace{WaveTrack.cpp}::IsValidChannel().

Here is the call graph for this function:

◆ Copy()

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

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.

Definition at line 55 of file LegacyAliasBlockFile.cpp.

56 {
57  auto newBlockFile = make_blockfile<LegacyAliasBlockFile>
58  (std::move(newFileName), wxFileNameWrapper{ mAliasedFileName },
59  mAliasStart, mLen, mAliasChannel,
60  mSummaryInfo.totalSummaryBytes, mSummaryInfo.fields < 3);
61 
62  return newBlockFile;
63 }

◆ Recover()

void LegacyAliasBlockFile::Recover ( void  )
override

Definition at line 148 of file LegacyAliasBlockFile.cpp.

148  {
149  WriteSummary();
150 }

◆ SaveXML()

void LegacyAliasBlockFile::SaveXML ( XMLWriter xmlFile)
override

Definition at line 65 of file LegacyAliasBlockFile.cpp.

67 {
68  xmlFile.StartTag(wxT("legacyblockfile"));
69 
70  xmlFile.WriteAttr(wxT("alias"), 1);
71  xmlFile.WriteAttr(wxT("name"), mFileName.GetFullName());
72  xmlFile.WriteAttr(wxT("aliaspath"), mAliasedFileName.GetFullPath());
73  xmlFile.WriteAttr(wxT("aliasstart"),
74  mAliasStart.as_long_long() );
75  xmlFile.WriteAttr(wxT("aliaslen"), mLen);
76  xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
77  xmlFile.WriteAttr(wxT("summarylen"), mSummaryInfo.totalSummaryBytes);
78  if (mSummaryInfo.fields < 3)
79  xmlFile.WriteAttr(wxT("norms"), 1);
80 
81  xmlFile.EndTag(wxT("legacyblockfile"));
82 }

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
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
XMLValueChecker::IsGoodPathName
static bool IsGoodPathName(const FilePath &strPathName)
Definition: XMLTagHandler.cpp:98
PCMAliasBlockFile
An AliasBlockFile that references uncompressed data in an existing file.
Definition: PCMAliasBlockFile.h:20
XMLValueChecker::IsGoodInt64
static bool IsGoodInt64(const wxString &strInt)
Check that the supplied string can be converted to a 64bit integer.
Definition: XMLTagHandler.cpp:163
floatSample
@ floatSample
Definition: SampleFormat.h:34
int16Sample
@ int16Sample
Definition: SampleFormat.h:32
XMLValueChecker::IsGoodFileName
static bool IsGoodFileName(const FilePath &strFileName, const FilePath &strDirName={})
Definition: XMLTagHandler.cpp:58
format
int format
Definition: ExportPCM.cpp:56
ComputeLegacySummaryInfo
void ComputeLegacySummaryInfo(const wxFileName &fileName, size_t summaryLen, sampleFormat format, SummaryInfo *info, bool noRMS, bool Silent, float *min, float *max, float *rms)
Definition: LegacyBlockFile.cpp:38
sampleFormat
sampleFormat
Definition: SampleFormat.h:29
anonymous_namespace{WaveTrack.cpp}::IsValidChannel
bool IsValidChannel(const int nValue)
Definition: WaveTrack.cpp:1706
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
XMLValueChecker::IsGoodPathString
static bool IsGoodPathString(const FilePath &str)
Definition: XMLTagHandler.cpp:105
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:76