1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-15 00:51:21 +01:00

Don't copy wxFileName often, it's not lightweight! Use wxFileNameWrapper...

... which is a new class that defines moves.
This commit is contained in:
Paul Licameli
2016-04-11 00:16:29 -04:00
committed by Paul Licameli
parent b0ef9c4e82
commit b6fdffbab2
23 changed files with 291 additions and 208 deletions

View File

@@ -20,14 +20,14 @@
#include "../FileFormats.h"
#include "../Internat.h"
LegacyAliasBlockFile::LegacyAliasBlockFile(wxFileName fileName,
wxFileName aliasedFileName,
LegacyAliasBlockFile::LegacyAliasBlockFile(wxFileNameWrapper &&fileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen,
int aliasChannel,
sampleCount summaryLen,
bool noRMS)
: PCMAliasBlockFile(fileName, aliasedFileName, aliasStart, aliasLen,
: PCMAliasBlockFile(std::move(fileName), std::move(aliasedFileName), aliasStart, aliasLen,
aliasChannel, 0.0, 0.0, 0.0)
{
sampleFormat format;
@@ -37,7 +37,7 @@ LegacyAliasBlockFile::LegacyAliasBlockFile(wxFileName fileName,
else
format = floatSample;
ComputeLegacySummaryInfo(fileName,
ComputeLegacySummaryInfo(mFileName,
summaryLen, format,
&mSummaryInfo, noRMS, FALSE,
&mMin, &mMax, &mRMS);
@@ -51,11 +51,11 @@ LegacyAliasBlockFile::~LegacyAliasBlockFile()
/// the summary data to a NEW file.
///
/// @param newFileName The filename to copy the summary data to.
BlockFile *LegacyAliasBlockFile::Copy(wxFileName newFileName)
BlockFile *LegacyAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
{
BlockFile *newBlockFile =
new LegacyAliasBlockFile(newFileName,
mAliasedFileName, mAliasStart,
new LegacyAliasBlockFile(std::move(newFileName),
wxFileNameWrapper{mAliasedFileName}, mAliasStart,
mLen, mAliasChannel,
mSummaryInfo.totalSummaryBytes,
mSummaryInfo.fields < 3);
@@ -85,8 +85,8 @@ void LegacyAliasBlockFile::SaveXML(XMLWriter &xmlFile)
// as testing will be done in DirManager::ProjectFSCK().
BlockFile *LegacyAliasBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs)
{
wxFileName summaryFileName;
wxFileName aliasFileName;
wxFileNameWrapper summaryFileName;
wxFileNameWrapper aliasFileName;
int aliasStart=0, aliasLen=0, aliasChannel=0;
int summaryLen=0;
bool noRMS = false;
@@ -133,7 +133,7 @@ BlockFile *LegacyAliasBlockFile::BuildFromXML(const wxString &projDir, const wxC
}
}
return new LegacyAliasBlockFile(summaryFileName, aliasFileName,
return new LegacyAliasBlockFile(std::move(summaryFileName), std::move(aliasFileName),
aliasStart, aliasLen, aliasChannel,
summaryLen, noRMS);
}

View File

@@ -22,8 +22,8 @@ class LegacyAliasBlockFile final : public PCMAliasBlockFile
// Constructor / Destructor
/// Constructs a LegacyAliasBlockFile, writing the summary to disk
LegacyAliasBlockFile(wxFileName fileName,
wxFileName aliasedFileName,
LegacyAliasBlockFile(wxFileNameWrapper &&fileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen,
int aliasChannel,
@@ -32,7 +32,7 @@ class LegacyAliasBlockFile final : public PCMAliasBlockFile
virtual ~LegacyAliasBlockFile();
void SaveXML(XMLWriter &xmlFile) override;
BlockFile *Copy(wxFileName fileName) override;
BlockFile *Copy(wxFileNameWrapper &&fileName) override;
void Recover() override;
static BlockFile *BuildFromXML(const wxString &projDir, const wxChar **attrs);

View File

@@ -36,7 +36,7 @@
#include "sndfile.h"
void ComputeLegacySummaryInfo(wxFileName fileName,
void ComputeLegacySummaryInfo(const wxFileName &fileName,
int summaryLen,
sampleFormat format,
SummaryInfo *info,
@@ -75,13 +75,14 @@ void ComputeLegacySummaryInfo(wxFileName fileName,
int read;
{
Maybe<wxLogNull> silence{};
wxFFile summaryFile(fileName.GetFullPath(), wxT("rb"));
const wxString fullPath{ fileName.GetFullPath() };
wxFFile summaryFile(fullPath, wxT("rb"));
if (Silent)
silence.create();
if (!summaryFile.IsOpened()) {
wxLogWarning(wxT("Unable to access summary file %s; substituting silence for remainder of session"),
fileName.GetFullPath().c_str());
fullPath.c_str());
read = info->frames64K * info->bytesPerFrame;
memset(data.ptr(), 0, read);
@@ -123,12 +124,12 @@ void ComputeLegacySummaryInfo(wxFileName fileName,
/// existing block file. This file must exist and be a valid block file.
///
/// @param existingFile The disk file this LegacyBlockFile should use.
LegacyBlockFile::LegacyBlockFile(wxFileName existingFile,
LegacyBlockFile::LegacyBlockFile(wxFileNameWrapper &&existingFile,
sampleFormat format,
sampleCount summaryLen,
sampleCount len,
bool noRMS):
BlockFile(existingFile, len),
BlockFile(std::move(existingFile), len),
mFormat(format)
{
@@ -139,7 +140,7 @@ LegacyBlockFile::LegacyBlockFile(wxFileName existingFile,
else
summaryFormat = floatSample;
ComputeLegacySummaryInfo(existingFile,
ComputeLegacySummaryInfo(mFileName,
summaryLen, summaryFormat,
&mSummaryInfo, noRMS, FALSE,
&mMin, &mMax, &mRMS);
@@ -293,7 +294,7 @@ void LegacyBlockFile::SaveXML(XMLWriter &xmlFile)
BlockFile *LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs,
sampleCount len, sampleFormat format)
{
wxFileName fileName;
wxFileNameWrapper fileName;
sampleCount summaryLen = 0;
bool noRMS = false;
long nValue;
@@ -324,21 +325,19 @@ BlockFile *LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar *
}
}
return new LegacyBlockFile(fileName, format, summaryLen, len, noRMS);
return new LegacyBlockFile(std::move(fileName), format, summaryLen, len, noRMS);
}
/// Create a copy of this BlockFile, but using a different disk file.
///
/// @param newFileName The name of the NEW file to use.
BlockFile *LegacyBlockFile::Copy(wxFileName newFileName)
BlockFile *LegacyBlockFile::Copy(wxFileNameWrapper &&newFileName)
{
BlockFile *newBlockFile = new LegacyBlockFile(newFileName,
return new LegacyBlockFile(std::move(newFileName),
mFormat,
mSummaryInfo.totalSummaryBytes,
mLen,
mSummaryInfo.fields < 3);
return newBlockFile;
}
wxLongLong LegacyBlockFile::GetSpaceUsage() const

View File

@@ -16,7 +16,7 @@
#include "../BlockFile.h"
void ComputeLegacySummaryInfo(wxFileName fileName,
void ComputeLegacySummaryInfo(const wxFileName &fileName,
int summaryLen,
sampleFormat format,
SummaryInfo *info,
@@ -38,7 +38,7 @@ class LegacyBlockFile final : public BlockFile {
// Constructor / Destructor
/// Create the memory structure to refer to the given block file
LegacyBlockFile(wxFileName existingFile,
LegacyBlockFile(wxFileNameWrapper &&existingFile,
sampleFormat format,
sampleCount summaryLen,
sampleCount len,
@@ -54,7 +54,7 @@ class LegacyBlockFile final : public BlockFile {
sampleCount start, sampleCount len) const override;
/// Create a NEW block file identical to this one
BlockFile *Copy(wxFileName newFileName) override;
BlockFile *Copy(wxFileNameWrapper &&newFileName) override;
/// Write an XML representation of this file
void SaveXML(XMLWriter &xmlFile) override;
wxLongLong GetSpaceUsage() const override;

View File

@@ -36,9 +36,10 @@ char bheaderTag[bheaderTagLen + 1] = "AudacityBlockFile112";
/// Create a disk file and write summary and sample data to it
ODDecodeBlockFile::ODDecodeBlockFile(wxFileName baseFileName,wxFileName audioFileName, sampleCount aliasStart,
ODDecodeBlockFile::ODDecodeBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&audioFileName, sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel,unsigned int decodeType):
SimpleBlockFile(baseFileName,NULL,aliasLen,floatSample,true,true), //floatSample has no effect. last two bools - bypass writing of blockfile and cache
SimpleBlockFile(std::move(baseFileName),
NULL,aliasLen,floatSample,true,true), //floatSample has no effect. last two bools - bypass writing of blockfile and cache
mType(decodeType),
mAliasStart(aliasStart),
@@ -46,15 +47,15 @@ ODDecodeBlockFile::ODDecodeBlockFile(wxFileName baseFileName,wxFileName audioFil
{
mDecoder = NULL;
mDataAvailable=false;
mAudioFileName = audioFileName;
mAudioFileName = std::move(audioFileName);
mFormat = int16Sample;
}
/// Create the memory structure to refer to the given block file
ODDecodeBlockFile::ODDecodeBlockFile(wxFileName existingFile, wxFileName audioFileName, sampleCount aliasStart,
ODDecodeBlockFile::ODDecodeBlockFile(wxFileNameWrapper &&existingFile, wxFileNameWrapper &&audioFileName, sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel, unsigned int decodeType,
float min, float max, float rms, bool dataAvailable):
SimpleBlockFile(existingFile,aliasLen,min,max,rms),
SimpleBlockFile(std::move(existingFile),aliasLen,min,max,rms),
mType(decodeType),
mAliasStart(aliasStart),
@@ -62,7 +63,7 @@ ODDecodeBlockFile::ODDecodeBlockFile(wxFileName existingFile, wxFileName audioFi
{
mDecoder = NULL;
mDataAvailable=dataAvailable;
mAudioFileName = audioFileName;
mAudioFileName = std::move(audioFileName);
mFormat = int16Sample;
}
@@ -157,7 +158,7 @@ bool ODDecodeBlockFile::Read64K(float *buffer, sampleCount start, sampleCount le
/// Construct a NEW PCMAliasBlockFile based on this one.
/// otherwise construct an ODPCMAliasBlockFile that still needs to be computed.
/// @param newFileName The filename to copy the summary data to.
BlockFile *ODDecodeBlockFile::Copy(wxFileName newFileName)
BlockFile *ODDecodeBlockFile::Copy(wxFileNameWrapper &&newFileName)
{
BlockFile *newBlockFile;
@@ -166,13 +167,13 @@ BlockFile *ODDecodeBlockFile::Copy(wxFileName newFileName)
if(IsSummaryAvailable())
{
//create a simpleblockfile, because once it has the summary it is a simpleblockfile for all intents an purposes
newBlockFile = SimpleBlockFile::Copy(newFileName) ;
newBlockFile = SimpleBlockFile::Copy(std::move(newFileName)) ;
}
else
{
//Summary File might exist in this case, but it probably (99.999% of the time) won't.
newBlockFile = new ODDecodeBlockFile(newFileName,
mAudioFileName, mAliasStart,
newBlockFile = new ODDecodeBlockFile(std::move(newFileName),
wxFileNameWrapper{mAudioFileName}, mAliasStart,
mLen, mAliasChannel, mType,
mMin, mMax, mRMS,IsSummaryAvailable());
//The client code will need to schedule this blockfile for OD decoding if it is going to a NEW track.
@@ -223,8 +224,8 @@ void ODDecodeBlockFile::SaveXML(XMLWriter &xmlFile)
// as testing will be done in DirManager::ProjectFSCK().
BlockFile *ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
{
wxFileName summaryFileName;
wxFileName audioFileName;
wxFileNameWrapper summaryFileName;
wxFileNameWrapper audioFileName;
sampleCount aliasStart=0, aliasLen=0;
int aliasChannel=0;
long nValue;
@@ -273,7 +274,7 @@ BlockFile *ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
}
}
return new ODDecodeBlockFile(summaryFileName, audioFileName,
return new ODDecodeBlockFile(std::move(summaryFileName), std::move(audioFileName),
aliasStart, aliasLen, aliasChannel,decodeType,
0,0,0, false);
@@ -355,10 +356,10 @@ int ODDecodeBlockFile::WriteODDecodeBlockFile()
}
///sets the file name the summary info will be saved in. threadsafe.
void ODDecodeBlockFile::SetFileName(wxFileName &name)
void ODDecodeBlockFile::SetFileName(wxFileNameWrapper &&name)
{
mFileNameMutex.Lock();
mFileName=name;
mFileName=std::move(name);
/* mchinen oct 9 2009 don't think we need the char* but leaving it in for now just as a reminder that we might
if wxFileName isn't threadsafe.
delete [] mFileNameChar;
@@ -585,9 +586,9 @@ void ODDecodeBlockFile::UnlockRead() const
/// 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().
void ODDecodeBlockFile::ChangeAudioFile(wxFileName newAudioFile)
void ODDecodeBlockFile::ChangeAudioFile(wxFileNameWrapper &&newAudioFile)
{
mAudioFileName = newAudioFile;
mAudioFileName = std::move(newAudioFile);
}

View File

@@ -42,10 +42,10 @@ class ODDecodeBlockFile final : public SimpleBlockFile
// Constructor / Destructor
/// Create a disk file and write summary and sample data to it
ODDecodeBlockFile(wxFileName baseFileName,wxFileName audioFileName, sampleCount aliasStart,
ODDecodeBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&audioFileName, sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel, unsigned int decodeType);
/// Create the memory structure to refer to the given block file
ODDecodeBlockFile(wxFileName existingFile, wxFileName audioFileName, sampleCount aliasStart,
ODDecodeBlockFile(wxFileNameWrapper &&existingFile, wxFileNameWrapper &&audioFileName, sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel, unsigned int decodeType,
float min, float max, float rms, bool dataAvailable);
@@ -77,7 +77,7 @@ class ODDecodeBlockFile final : public SimpleBlockFile
///Makes NEW ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability
BlockFile *Copy(wxFileName fileName) override;
BlockFile *Copy(wxFileNameWrapper &&fileName) override;
///Saves as xml ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability
void SaveXML(XMLWriter &xmlFile) override;
@@ -129,10 +129,10 @@ class ODDecodeBlockFile final : public SimpleBlockFile
///set the decoder,
void SetODFileDecoder(ODFileDecoder* decoder);
wxFileName GetAudioFileName(){return mAudioFileName;}
const wxFileName &GetAudioFileName(){return mAudioFileName;}
///sets the file name the summary info will be saved in. threadsafe.
void SetFileName(wxFileName &name) override;
void SetFileName(wxFileNameWrapper &&name) override;
wxFileName GetFileName() const override;
/// Prevents a read on other threads of the encoded audio file.
@@ -142,7 +142,7 @@ class ODDecodeBlockFile final : public SimpleBlockFile
///// Get the name of the file where the audio data for this block is
/// stored.
wxFileName GetEncodedAudioFilename()
const wxFileName &GetEncodedAudioFilename()
{
return mAudioFileName;
}
@@ -150,7 +150,7 @@ class ODDecodeBlockFile final : public SimpleBlockFile
/// 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().
void ChangeAudioFile(wxFileName newAudioFile);
void ChangeAudioFile(wxFileNameWrapper &&newAudioFile);
protected:
@@ -165,7 +165,7 @@ class ODDecodeBlockFile final : public SimpleBlockFile
mutable ODLock mFileNameMutex;
///The original file the audio came from.
wxFileName mAudioFileName;
wxFileNameWrapper mAudioFileName;
mutable ODLock mDataAvailableMutex;
bool mDataAvailable;

View File

@@ -45,11 +45,11 @@ char aheaderTag[aheaderTagLen + 1] = "AudacityBlockFile112";
ODPCMAliasBlockFile::ODPCMAliasBlockFile(
wxFileName fileName,
wxFileName aliasedFileName,
wxFileNameWrapper &&fileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel)
: PCMAliasBlockFile(fileName, aliasedFileName,
: PCMAliasBlockFile(std::move(fileName), std::move(aliasedFileName),
aliasStart, aliasLen, aliasChannel,false)
{
mSummaryAvailable = mSummaryBeingComputed = mHasBeenSaved = false;
@@ -57,12 +57,12 @@ ODPCMAliasBlockFile::ODPCMAliasBlockFile(
///summaryAvailable should be true if the file has been written already.
ODPCMAliasBlockFile::ODPCMAliasBlockFile(
wxFileName existingSummaryFileName,
wxFileName aliasedFileName,
wxFileNameWrapper &&existingSummaryFileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel,
float min, float max, float rms, bool summaryAvailable)
: PCMAliasBlockFile(existingSummaryFileName, aliasedFileName,
: PCMAliasBlockFile(std::move(existingSummaryFileName), std::move(aliasedFileName),
aliasStart, aliasLen,
aliasChannel, min, max, rms)
{
@@ -216,7 +216,7 @@ bool ODPCMAliasBlockFile::Read64K(float *buffer, sampleCount start, sampleCount
/// Construct a NEW PCMAliasBlockFile based on this one.
/// otherwise construct an ODPCMAliasBlockFile that still needs to be computed.
/// @param newFileName The filename to copy the summary data to.
BlockFile *ODPCMAliasBlockFile::Copy(wxFileName newFileName)
BlockFile *ODPCMAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
{
BlockFile *newBlockFile;
@@ -228,8 +228,8 @@ BlockFile *ODPCMAliasBlockFile::Copy(wxFileName newFileName)
//PCMAliasBlockFile is to lock on exit, and this will cause orphaned blockfiles..
if(IsSummaryAvailable() && mHasBeenSaved)
{
newBlockFile = new PCMAliasBlockFile(newFileName,
mAliasedFileName, mAliasStart,
newBlockFile = new PCMAliasBlockFile(std::move(newFileName),
wxFileNameWrapper{mAliasedFileName}, mAliasStart,
mLen, mAliasChannel,
mMin, mMax, mRMS);
@@ -237,8 +237,8 @@ BlockFile *ODPCMAliasBlockFile::Copy(wxFileName newFileName)
else
{
//Summary File might exist in this case, but it might not.
newBlockFile = new ODPCMAliasBlockFile(newFileName,
mAliasedFileName, mAliasStart,
newBlockFile = new ODPCMAliasBlockFile(std::move(newFileName),
wxFileNameWrapper{mAliasedFileName}, mAliasStart,
mLen, mAliasChannel,
mMin, mMax, mRMS,IsSummaryAvailable());
//The client code will need to schedule this blockfile for OD summarizing if it is going to a NEW track.
@@ -292,8 +292,8 @@ void ODPCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
// as testing will be done in DirManager::ProjectFSCK().
BlockFile *ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
{
wxFileName summaryFileName;
wxFileName aliasFileName;
wxFileNameWrapper summaryFileName;
wxFileNameWrapper aliasFileName;
sampleCount aliasStart=0, aliasLen=0;
int aliasChannel=0;
long nValue;
@@ -339,7 +339,7 @@ BlockFile *ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attr
}
}
return new ODPCMAliasBlockFile(summaryFileName, aliasFileName,
return new ODPCMAliasBlockFile(std::move(summaryFileName), std::move(aliasFileName),
aliasStart, aliasLen, aliasChannel,
0,0,0, false);
}
@@ -373,10 +373,10 @@ void ODPCMAliasBlockFile::DoWriteSummary()
}
///sets the file name the summary info will be saved in. threadsafe.
void ODPCMAliasBlockFile::SetFileName(wxFileName &name)
void ODPCMAliasBlockFile::SetFileName(wxFileNameWrapper &&name)
{
mFileNameMutex.Lock();
mFileName=name;
mFileName = std::move(name);
mFileNameMutex.Unlock();
}

View File

@@ -47,11 +47,11 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile
{
public:
/// Constructs a PCMAliasBlockFile, writing the summary to disk
ODPCMAliasBlockFile(wxFileName baseFileName,
wxFileName aliasedFileName, sampleCount aliasStart,
ODPCMAliasBlockFile(wxFileNameWrapper &&baseFileName,
wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel);
ODPCMAliasBlockFile(wxFileName existingSummaryFileName,
wxFileName aliasedFileName, sampleCount aliasStart,
ODPCMAliasBlockFile(wxFileNameWrapper &&existingSummaryFileName,
wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel,
float min, float max, float rms, bool summaryAvailable);
virtual ~ODPCMAliasBlockFile();
@@ -75,7 +75,7 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile
bool Read64K(float *buffer, sampleCount start, sampleCount len) override;
///Makes NEW ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability
BlockFile *Copy(wxFileName fileName) override;
BlockFile *Copy(wxFileNameWrapper &&fileName) override;
///Saves as xml ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability
void SaveXML(XMLWriter &xmlFile) override;
@@ -124,7 +124,7 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile
bool ReadSummary(void *data) override;
///sets the file name the summary info will be saved in. threadsafe.
void SetFileName(wxFileName &name) override;
void SetFileName(wxFileNameWrapper &&name) override;
wxFileName GetFileName() const override;
//when the file closes, it locks the blockfiles, but only conditionally.

View File

@@ -28,22 +28,22 @@
extern AudioIO *gAudioIO;
PCMAliasBlockFile::PCMAliasBlockFile(
wxFileName fileName,
wxFileName aliasedFileName,
wxFileNameWrapper &&fileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel)
: AliasBlockFile(fileName, aliasedFileName,
: AliasBlockFile(std::move(fileName), std::move(aliasedFileName),
aliasStart, aliasLen, aliasChannel)
{
AliasBlockFile::WriteSummary();
}
PCMAliasBlockFile::PCMAliasBlockFile(
wxFileName fileName,
wxFileName aliasedFileName,
wxFileNameWrapper&& fileName,
wxFileNameWrapper&& aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel,bool writeSummary)
: AliasBlockFile(fileName, aliasedFileName,
: AliasBlockFile(std::move(fileName), std::move(aliasedFileName),
aliasStart, aliasLen, aliasChannel)
{
if(writeSummary)
@@ -51,12 +51,12 @@ PCMAliasBlockFile::PCMAliasBlockFile(
}
PCMAliasBlockFile::PCMAliasBlockFile(
wxFileName existingSummaryFileName,
wxFileName aliasedFileName,
wxFileNameWrapper &&existingSummaryFileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel,
float min, float max, float rms)
: AliasBlockFile(existingSummaryFileName, aliasedFileName,
: AliasBlockFile(std::move(existingSummaryFileName), std::move(aliasedFileName),
aliasStart, aliasLen,
aliasChannel, min, max, rms)
{
@@ -148,10 +148,10 @@ int PCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format,
/// the summary data to a NEW file.
///
/// @param newFileName The filename to copy the summary data to.
BlockFile *PCMAliasBlockFile::Copy(wxFileName newFileName)
BlockFile *PCMAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
{
BlockFile *newBlockFile = new PCMAliasBlockFile(newFileName,
mAliasedFileName, mAliasStart,
BlockFile *newBlockFile = new PCMAliasBlockFile(std::move(newFileName),
wxFileNameWrapper{mAliasedFileName}, mAliasStart,
mLen, mAliasChannel,
mMin, mMax, mRMS);
@@ -179,8 +179,8 @@ void PCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
// as testing will be done in DirManager::ProjectFSCK().
BlockFile *PCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
{
wxFileName summaryFileName;
wxFileName aliasFileName;
wxFileNameWrapper summaryFileName;
wxFileNameWrapper aliasFileName;
int aliasStart=0, aliasLen=0, aliasChannel=0;
float min = 0.0f, max = 0.0f, rms = 0.0f;
double dblValue;
@@ -247,7 +247,7 @@ BlockFile *PCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
}
}
return new PCMAliasBlockFile(summaryFileName, aliasFileName,
return new PCMAliasBlockFile(std::move(summaryFileName), std::move(aliasFileName),
aliasStart, aliasLen, aliasChannel,
min, max, rms);
}

View File

@@ -19,18 +19,18 @@ class PCMAliasBlockFile /* not final */ : public AliasBlockFile
{
public:
/// Constructs a PCMAliasBlockFile, writing the summary to disk
PCMAliasBlockFile(wxFileName baseFileName,
wxFileName aliasedFileName,
PCMAliasBlockFile(wxFileNameWrapper &&baseFileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel);
///Constructs a PCMAliasBlockFile with the option of not writing to disk
PCMAliasBlockFile(wxFileName fileName,
wxFileName aliasedFileName,
PCMAliasBlockFile(wxFileNameWrapper &&fileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel,bool writeSummary);
PCMAliasBlockFile(wxFileName existingSummaryFileName,
wxFileName aliasedFileName,
PCMAliasBlockFile(wxFileNameWrapper &&existingSummaryFileName,
wxFileNameWrapper &&aliasedFileName,
sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel,
float min, float max, float rms);
@@ -41,7 +41,7 @@ class PCMAliasBlockFile /* not final */ : public AliasBlockFile
sampleCount start, sampleCount len) const override;
void SaveXML(XMLWriter &xmlFile) override;
BlockFile *Copy(wxFileName fileName) override;
BlockFile *Copy(wxFileNameWrapper &&fileName) override;
void Recover() override;
static BlockFile *BuildFromXML(DirManager &dm, const wxChar **attrs);

View File

@@ -13,7 +13,7 @@
#include "../FileFormats.h"
SilentBlockFile::SilentBlockFile(sampleCount sampleLen):
BlockFile(wxFileName(), sampleLen)
BlockFile(wxFileNameWrapper{}, sampleLen)
{
mMin = 0.;
mMax = 0.;
@@ -75,7 +75,7 @@ BlockFile *SilentBlockFile::BuildFromXML(DirManager & WXUNUSED(dm), const wxChar
}
/// Create a copy of this BlockFile
BlockFile *SilentBlockFile::Copy(wxFileName newFileName)
BlockFile *SilentBlockFile::Copy(wxFileNameWrapper &&)
{
BlockFile *newBlockFile = new SilentBlockFile(mLen);

View File

@@ -39,7 +39,7 @@ class SilentBlockFile final : public BlockFile {
sampleCount start, sampleCount len) const override;
/// Create a NEW block file identical to this one
BlockFile *Copy(wxFileName newFileName) override;
BlockFile *Copy(wxFileNameWrapper &&newFileName) override;
/// Write an XML representation of this file
void SaveXML(XMLWriter &xmlFile) override;
wxLongLong GetSpaceUsage() const override;

View File

@@ -95,12 +95,15 @@ static wxUint32 SwapUintEndianess(wxUint32 in)
/// @param sampleLen The number of samples to be written to this block.
/// @param format The format of the given samples.
/// @param allowDeferredWrite Allow deferred write-caching
SimpleBlockFile::SimpleBlockFile(wxFileName baseFileName,
SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&baseFileName,
samplePtr sampleData, sampleCount sampleLen,
sampleFormat format,
bool allowDeferredWrite /* = false */,
bool bypassCache /* = false */):
BlockFile(wxFileName(baseFileName.GetFullPath() + wxT(".au")), sampleLen)
BlockFile {
(baseFileName.SetExt(wxT("au")), std::move(baseFileName)),
sampleLen
}
{
mFormat = format;
@@ -136,9 +139,9 @@ SimpleBlockFile::SimpleBlockFile(wxFileName baseFileName,
/// existing block file. This file must exist and be a valid block file.
///
/// @param existingFile The disk file this SimpleBlockFile should use.
SimpleBlockFile::SimpleBlockFile(wxFileName existingFile, sampleCount len,
SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&existingFile, sampleCount len,
float min, float max, float rms):
BlockFile(existingFile, len)
BlockFile(std::move(existingFile), len)
{
// Set an invalid format to force GetSpaceUsage() to read it from the file.
mFormat = (sampleFormat) 0;
@@ -490,7 +493,7 @@ void SimpleBlockFile::SaveXML(XMLWriter &xmlFile)
/// static
BlockFile *SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
{
wxFileName fileName;
wxFileNameWrapper fileName;
float min = 0.0f, max = 0.0f, rms = 0.0f;
sampleCount len = 0;
double dblValue;
@@ -528,15 +531,15 @@ BlockFile *SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
}
}
return new SimpleBlockFile(fileName, len, min, max, rms);
return new SimpleBlockFile(std::move(fileName), len, min, max, rms);
}
/// Create a copy of this BlockFile, but using a different disk file.
///
/// @param newFileName The name of the NEW file to use.
BlockFile *SimpleBlockFile::Copy(wxFileName newFileName)
BlockFile *SimpleBlockFile::Copy(wxFileNameWrapper &&newFileName)
{
BlockFile *newBlockFile = new SimpleBlockFile(newFileName, mLen,
BlockFile *newBlockFile = new SimpleBlockFile(std::move(newFileName), mLen,
mMin, mMax, mRMS);
return newBlockFile;

View File

@@ -48,13 +48,13 @@ class PROFILE_DLL_API SimpleBlockFile /* not final */ : public BlockFile {
// Constructor / Destructor
/// Create a disk file and write summary and sample data to it
SimpleBlockFile(wxFileName baseFileName,
SimpleBlockFile(wxFileNameWrapper &&baseFileName,
samplePtr sampleData, sampleCount sampleLen,
sampleFormat format,
bool allowDeferredWrite = false,
bool bypassCache = false );
/// Create the memory structure to refer to the given block file
SimpleBlockFile(wxFileName existingFile, sampleCount len,
SimpleBlockFile(wxFileNameWrapper &&existingFile, sampleCount len,
float min, float max, float rms);
virtual ~SimpleBlockFile();
@@ -68,7 +68,7 @@ class PROFILE_DLL_API SimpleBlockFile /* not final */ : public BlockFile {
sampleCount start, sampleCount len) const override;
/// Create a NEW block file identical to this one
BlockFile *Copy(wxFileName newFileName) override;
BlockFile *Copy(wxFileNameWrapper &&newFileName) override;
/// Write an XML representation of this file
void SaveXML(XMLWriter &xmlFile) override;