mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-14 07:10:24 +02: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:
parent
b0ef9c4e82
commit
b6fdffbab2
@ -2969,6 +2969,7 @@
|
||||
28FEC1B21A12B6FB00FACE48 /* EffectAutomationParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EffectAutomationParameters.h; path = ../include/audacity/EffectAutomationParameters.h; sourceTree = SOURCE_ROOT; };
|
||||
5E61EE0C1CBAA6BB0009FCF1 /* MemoryX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryX.h; sourceTree = "<group>"; };
|
||||
5ED18DB61CC16B1E00FAFE95 /* Reverb_libSoX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reverb_libSoX.h; sourceTree = "<group>"; };
|
||||
5ED18DB71CC290AB00FAFE95 /* wxFileNameWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wxFileNameWrapper.h; sourceTree = "<group>"; };
|
||||
82FF184D13CF01A600C1B664 /* dBTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dBTable.cpp; path = sbsms/src/dBTable.cpp; sourceTree = "<group>"; };
|
||||
82FF184E13CF01A600C1B664 /* dBTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dBTable.h; path = sbsms/src/dBTable.h; sourceTree = "<group>"; };
|
||||
82FF184F13CF01A600C1B664 /* slide.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = slide.cpp; path = sbsms/src/slide.cpp; sourceTree = "<group>"; };
|
||||
@ -3792,6 +3793,7 @@
|
||||
1790AFC409883BFD008A330A /* src */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5ED18DB71CC290AB00FAFE95 /* wxFileNameWrapper.h */,
|
||||
1790AFC709883BFD008A330A /* AboutDialog.cpp */,
|
||||
1790AFC909883BFD008A330A /* AColor.cpp */,
|
||||
1790AFCE09883BFD008A330A /* AudacityApp.cpp */,
|
||||
|
@ -99,10 +99,10 @@ ArrayOf<char> BlockFile::fullSummary;
|
||||
/// will store at least the summary data here.
|
||||
///
|
||||
/// @param samples The number of samples this BlockFile contains.
|
||||
BlockFile::BlockFile(wxFileName fileName, sampleCount samples):
|
||||
BlockFile::BlockFile(wxFileNameWrapper &&fileName, sampleCount samples):
|
||||
mLockCount(0),
|
||||
mRefCount(1),
|
||||
mFileName(fileName),
|
||||
mFileName(std::move(fileName)),
|
||||
mLen(samples),
|
||||
mSummaryInfo(samples)
|
||||
{
|
||||
@ -126,9 +126,9 @@ wxFileName BlockFile::GetFileName() const
|
||||
}
|
||||
|
||||
///sets the file name the summary info will be saved in. threadsafe.
|
||||
void BlockFile::SetFileName(wxFileName &name)
|
||||
void BlockFile::SetFileName(wxFileNameWrapper &&name)
|
||||
{
|
||||
mFileName=name;
|
||||
mFileName=std::move(name);
|
||||
}
|
||||
|
||||
|
||||
@ -523,26 +523,29 @@ bool BlockFile::Read64K(float *buffer,
|
||||
/// file.
|
||||
/// @param aliasChannel The channel where this block's data is located in
|
||||
/// the aliased file
|
||||
AliasBlockFile::AliasBlockFile(wxFileName baseFileName,
|
||||
wxFileName aliasedFileName,
|
||||
AliasBlockFile::AliasBlockFile(wxFileNameWrapper &&baseFileName,
|
||||
wxFileNameWrapper &&aliasedFileName,
|
||||
sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel):
|
||||
BlockFile(wxFileName(baseFileName.GetFullPath() + wxT(".auf")), aliasLen),
|
||||
mAliasedFileName(aliasedFileName),
|
||||
BlockFile {
|
||||
(baseFileName.SetExt(wxT("auf")), std::move(baseFileName)),
|
||||
aliasLen
|
||||
},
|
||||
mAliasedFileName(std::move(aliasedFileName)),
|
||||
mAliasStart(aliasStart),
|
||||
mAliasChannel(aliasChannel)
|
||||
{
|
||||
mSilentAliasLog=FALSE;
|
||||
}
|
||||
|
||||
AliasBlockFile::AliasBlockFile(wxFileName existingSummaryFileName,
|
||||
wxFileName aliasedFileName,
|
||||
AliasBlockFile::AliasBlockFile(wxFileNameWrapper &&existingSummaryFileName,
|
||||
wxFileNameWrapper &&aliasedFileName,
|
||||
sampleCount aliasStart,
|
||||
sampleCount aliasLen,
|
||||
int aliasChannel,
|
||||
float min, float max, float rms):
|
||||
BlockFile(existingSummaryFileName, aliasLen),
|
||||
mAliasedFileName(aliasedFileName),
|
||||
BlockFile(std::move(existingSummaryFileName), aliasLen),
|
||||
mAliasedFileName(std::move(aliasedFileName)),
|
||||
mAliasStart(aliasStart),
|
||||
mAliasChannel(aliasChannel)
|
||||
{
|
||||
@ -629,9 +632,9 @@ bool AliasBlockFile::ReadSummary(void *data)
|
||||
/// 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 AliasBlockFile::ChangeAliasedFileName(wxFileName newAliasedFile)
|
||||
void AliasBlockFile::ChangeAliasedFileName(wxFileNameWrapper &&newAliasedFile)
|
||||
{
|
||||
mAliasedFileName = newAliasedFile;
|
||||
mAliasedFileName = std::move(newAliasedFile);
|
||||
}
|
||||
|
||||
wxLongLong AliasBlockFile::GetSpaceUsage() const
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "SampleFormat.h"
|
||||
|
||||
#include "wxFileNameWrapper.h"
|
||||
|
||||
|
||||
class SummaryInfo {
|
||||
public:
|
||||
@ -45,7 +47,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
||||
// Constructor / Destructor
|
||||
|
||||
/// Construct a BlockFile.
|
||||
BlockFile(wxFileName fileName, sampleCount samples);
|
||||
BlockFile(wxFileNameWrapper &&fileName, sampleCount samples);
|
||||
virtual ~BlockFile();
|
||||
|
||||
// Reading
|
||||
@ -71,7 +73,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
||||
/// (can be empty -- some BlockFiles, like SilentBlockFile, correspond to
|
||||
/// no file on disk)
|
||||
virtual wxFileName GetFileName() const;
|
||||
virtual void SetFileName(wxFileName &name);
|
||||
virtual void SetFileName(wxFileNameWrapper &&name);
|
||||
|
||||
virtual sampleCount GetLength() const { return mLen; }
|
||||
virtual void SetLength(const sampleCount newLen) { mLen = newLen; }
|
||||
@ -106,7 +108,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
||||
virtual bool IsSummaryBeingComputed(){return false;}
|
||||
|
||||
/// Create a NEW BlockFile identical to this, using the given filename
|
||||
virtual BlockFile *Copy(wxFileName newFileName) = 0;
|
||||
virtual BlockFile * Copy(wxFileNameWrapper &&newFileName) = 0;
|
||||
|
||||
virtual wxLongLong GetSpaceUsage() const = 0;
|
||||
|
||||
@ -164,7 +166,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
||||
static ArrayOf<char> fullSummary;
|
||||
|
||||
protected:
|
||||
wxFileName mFileName;
|
||||
wxFileNameWrapper mFileName;
|
||||
sampleCount mLen;
|
||||
SummaryInfo mSummaryInfo;
|
||||
float mMin, mMax, mRMS;
|
||||
@ -187,11 +189,11 @@ class AliasBlockFile /* not final */ : public BlockFile
|
||||
// Constructor / Destructor
|
||||
|
||||
/// Constructs an AliasBlockFile
|
||||
AliasBlockFile(wxFileName baseFileName,
|
||||
wxFileName aliasedFileName, sampleCount aliasStart,
|
||||
AliasBlockFile(wxFileNameWrapper &&baseFileName,
|
||||
wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel);
|
||||
AliasBlockFile(wxFileName existingSummaryFileName,
|
||||
wxFileName aliasedFileName, sampleCount aliasStart,
|
||||
AliasBlockFile(wxFileNameWrapper &&existingSummaryFileName,
|
||||
wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel,
|
||||
float min, float max, float RMS);
|
||||
virtual ~AliasBlockFile();
|
||||
@ -207,8 +209,8 @@ class AliasBlockFile /* not final */ : public BlockFile
|
||||
//
|
||||
// These methods are for advanced use only!
|
||||
//
|
||||
wxFileName GetAliasedFileName() { return mAliasedFileName; }
|
||||
void ChangeAliasedFileName(wxFileName newAliasedFile);
|
||||
const wxFileName &GetAliasedFileName() { return mAliasedFileName; }
|
||||
void ChangeAliasedFileName(wxFileNameWrapper &&newAliasedFile);
|
||||
bool IsAlias() const override { return true; }
|
||||
|
||||
protected:
|
||||
@ -218,7 +220,7 @@ class AliasBlockFile /* not final */ : public BlockFile
|
||||
/// Read the summary into a buffer
|
||||
bool ReadSummary(void *data) override;
|
||||
|
||||
wxFileName mAliasedFileName;
|
||||
wxFileNameWrapper mAliasedFileName;
|
||||
sampleCount mAliasStart;
|
||||
int mAliasChannel;
|
||||
mutable bool mSilentAliasLog;
|
||||
|
@ -560,9 +560,9 @@ void DirManager::SetLocalTempDir(const wxString &path)
|
||||
mytemp = path;
|
||||
}
|
||||
|
||||
wxFileName DirManager::MakeBlockFilePath(const wxString &value) {
|
||||
wxFileNameWrapper DirManager::MakeBlockFilePath(const wxString &value) {
|
||||
|
||||
wxFileName dir;
|
||||
wxFileNameWrapper dir;
|
||||
dir.AssignDir(GetDataFilesDir());
|
||||
|
||||
if(value.GetChar(0)==wxT('d')){
|
||||
@ -571,7 +571,8 @@ wxFileName DirManager::MakeBlockFilePath(const wxString &value) {
|
||||
wxString subdir=value.Mid(0,location);
|
||||
dir.AppendDir(subdir);
|
||||
|
||||
if(!dir.DirExists())dir.Mkdir();
|
||||
if(!dir.DirExists())
|
||||
dir.Mkdir();
|
||||
}
|
||||
|
||||
if(value.GetChar(0)==wxT('e')){
|
||||
@ -588,14 +589,14 @@ wxFileName DirManager::MakeBlockFilePath(const wxString &value) {
|
||||
wxLogSysError(_("mkdir in DirManager::MakeBlockFilePath failed."));
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
return std::move(dir);
|
||||
}
|
||||
|
||||
bool DirManager::AssignFile(wxFileName &fileName,
|
||||
bool DirManager::AssignFile(wxFileNameWrapper &fileName,
|
||||
const wxString &value,
|
||||
bool diskcheck)
|
||||
{
|
||||
wxFileName dir=MakeBlockFilePath(value);
|
||||
wxFileNameWrapper dir{ MakeBlockFilePath(value) };
|
||||
|
||||
if(diskcheck){
|
||||
// verify that there's no possible collision on disk. If there
|
||||
@ -755,9 +756,9 @@ void DirManager::BalanceInfoDel(const wxString &file)
|
||||
|
||||
// only determines appropriate filename and subdir balance; does not
|
||||
// perform maintainence
|
||||
wxFileName DirManager::MakeBlockFileName()
|
||||
wxFileNameWrapper DirManager::MakeBlockFileName()
|
||||
{
|
||||
wxFileName ret;
|
||||
wxFileNameWrapper ret;
|
||||
wxString baseFileName;
|
||||
|
||||
unsigned int filenum,midnum,topnum,midkey;
|
||||
@ -863,7 +864,7 @@ wxFileName DirManager::MakeBlockFileName()
|
||||
// FIXME: Might we get here without midkey having been set?
|
||||
// Seemed like a possible problem in these changes in .aup directory hierarchy.
|
||||
BalanceFileAdd(midkey);
|
||||
return ret;
|
||||
return std::move(ret);
|
||||
}
|
||||
|
||||
BlockFile *DirManager::NewSimpleBlockFile(
|
||||
@ -871,13 +872,14 @@ BlockFile *DirManager::NewSimpleBlockFile(
|
||||
sampleFormat format,
|
||||
bool allowDeferredWrite)
|
||||
{
|
||||
wxFileName fileName = MakeBlockFileName();
|
||||
wxFileNameWrapper filePath{ MakeBlockFileName() };
|
||||
const wxString fileName{ filePath.GetName() };
|
||||
|
||||
BlockFile *newBlockFile =
|
||||
new SimpleBlockFile(fileName, sampleData, sampleLen, format,
|
||||
new SimpleBlockFile(std::move(filePath), sampleData, sampleLen, format,
|
||||
allowDeferredWrite);
|
||||
|
||||
mBlockFileHash[fileName.GetName()]=newBlockFile;
|
||||
mBlockFileHash[fileName]=newBlockFile;
|
||||
|
||||
return newBlockFile;
|
||||
}
|
||||
@ -886,13 +888,15 @@ BlockFile *DirManager::NewAliasBlockFile(
|
||||
const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel)
|
||||
{
|
||||
wxFileName fileName = MakeBlockFileName();
|
||||
wxFileNameWrapper filePath{ MakeBlockFileName() };
|
||||
const wxString fileName = filePath.GetName();
|
||||
|
||||
BlockFile *newBlockFile =
|
||||
new PCMAliasBlockFile(fileName,
|
||||
aliasedFile, aliasStart, aliasLen, aliasChannel);
|
||||
new PCMAliasBlockFile(std::move(filePath),
|
||||
wxFileNameWrapper{aliasedFile},
|
||||
aliasStart, aliasLen, aliasChannel);
|
||||
|
||||
mBlockFileHash[fileName.GetName()]=newBlockFile;
|
||||
mBlockFileHash[fileName]=newBlockFile;
|
||||
aliasList.Add(aliasedFile);
|
||||
|
||||
return newBlockFile;
|
||||
@ -902,13 +906,14 @@ BlockFile *DirManager::NewODAliasBlockFile(
|
||||
const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel)
|
||||
{
|
||||
wxFileName fileName = MakeBlockFileName();
|
||||
wxFileNameWrapper filePath{ MakeBlockFileName() };
|
||||
const wxString fileName{ filePath.GetName() };
|
||||
|
||||
BlockFile *newBlockFile =
|
||||
new ODPCMAliasBlockFile(fileName,
|
||||
aliasedFile, aliasStart, aliasLen, aliasChannel);
|
||||
new ODPCMAliasBlockFile(std::move(filePath),
|
||||
wxFileNameWrapper{aliasedFile}, aliasStart, aliasLen, aliasChannel);
|
||||
|
||||
mBlockFileHash[fileName.GetName()]=newBlockFile;
|
||||
mBlockFileHash[fileName]=newBlockFile;
|
||||
aliasList.Add(aliasedFile);
|
||||
|
||||
return newBlockFile;
|
||||
@ -918,13 +923,14 @@ BlockFile *DirManager::NewODDecodeBlockFile(
|
||||
const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel, int decodeType)
|
||||
{
|
||||
wxFileName fileName = MakeBlockFileName();
|
||||
wxFileNameWrapper filePath{ MakeBlockFileName() };
|
||||
const wxString fileName{ filePath.GetName() };
|
||||
|
||||
BlockFile *newBlockFile =
|
||||
new ODDecodeBlockFile(fileName,
|
||||
aliasedFile, aliasStart, aliasLen, aliasChannel, decodeType);
|
||||
new ODDecodeBlockFile(std::move(filePath),
|
||||
wxFileNameWrapper{aliasedFile}, aliasStart, aliasLen, aliasChannel, decodeType);
|
||||
|
||||
mBlockFileHash[fileName.GetName()]=newBlockFile;
|
||||
mBlockFileHash[fileName]=newBlockFile;
|
||||
aliasList.Add(aliasedFile); //OD TODO: check to see if we need to remove this when done decoding.
|
||||
//I don't immediately see a place where aliased files remove when a file is closed.
|
||||
|
||||
@ -970,10 +976,12 @@ BlockFile *DirManager::CopyBlockFile(BlockFile *b)
|
||||
if (!fn.IsOk())
|
||||
// Block files with uninitialized filename (i.e. SilentBlockFile)
|
||||
// just need an in-memory copy.
|
||||
b2 = b->Copy(wxFileName());
|
||||
b2 = b->Copy(wxFileNameWrapper{});
|
||||
else
|
||||
{
|
||||
wxFileName newFile = MakeBlockFileName();
|
||||
wxFileNameWrapper newFile{ MakeBlockFileName() };
|
||||
const wxString newName{newFile.GetName()};
|
||||
const wxString newPath{ newFile.GetFullPath() };
|
||||
|
||||
// We assume that the NEW file should have the same extension
|
||||
// as the existing file
|
||||
@ -988,13 +996,13 @@ BlockFile *DirManager::CopyBlockFile(BlockFile *b)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b2 = b->Copy(newFile);
|
||||
b2 = b->Copy(std::move(newFile));
|
||||
|
||||
if (b2 == NULL)
|
||||
return NULL;
|
||||
|
||||
mBlockFileHash[newFile.GetName()]=b2;
|
||||
aliasList.Add(newFile.GetFullPath());
|
||||
mBlockFileHash[newName]=b2;
|
||||
aliasList.Add(newPath);
|
||||
}
|
||||
|
||||
return b2;
|
||||
@ -1115,23 +1123,23 @@ bool DirManager::MoveOrCopyToNewProjectDirectory(BlockFile *f, bool copy)
|
||||
return true;
|
||||
}
|
||||
|
||||
wxFileName newFileName;
|
||||
wxFileNameWrapper newFileName;
|
||||
if (!this->AssignFile(newFileName, oldFileName.GetFullName(), false))
|
||||
return false;
|
||||
|
||||
if (newFileName != oldFileName) {
|
||||
//check to see that summary exists before we copy.
|
||||
bool summaryExisted = f->IsSummaryAvailable();
|
||||
auto oldPath = oldFileName.GetFullPath();
|
||||
auto newPath = newFileName.GetFullPath();
|
||||
if (summaryExisted) {
|
||||
auto oldPath = oldFileName.GetFullPath();
|
||||
auto newPath = newFileName.GetFullPath();
|
||||
auto success = copy
|
||||
? wxCopyFile(oldPath, newPath)
|
||||
: wxRenameFile(oldPath, newPath);
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
f->SetFileName(newFileName);
|
||||
f->SetFileName(std::move(newFileName));
|
||||
|
||||
//there is a small chance that the summary has begun to be computed on a different thread with the
|
||||
//original filename. we need to catch this case by waiting for it to finish and then copy.
|
||||
@ -1145,9 +1153,7 @@ bool DirManager::MoveOrCopyToNewProjectDirectory(BlockFile *f, bool copy)
|
||||
//if it doesn't, we can assume it was written to the NEW name, which is fine.
|
||||
if (oldFileName.FileExists())
|
||||
{
|
||||
auto oldPath = oldFileName.GetFullPath();
|
||||
bool ok = wxCopyFile(oldPath,
|
||||
newFileName.GetFullPath());
|
||||
bool ok = wxCopyFile(oldPath, newPath);
|
||||
if(ok && !copy)
|
||||
wxRemoveFile(oldPath);
|
||||
else if (!ok)
|
||||
@ -1201,12 +1207,13 @@ void DirManager::Deref(BlockFile * f)
|
||||
}
|
||||
}
|
||||
|
||||
bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
bool DirManager::EnsureSafeFilename(const wxFileName &fName)
|
||||
{
|
||||
// Quick check: If it's not even in our alias list,
|
||||
// then the file name is A-OK.
|
||||
|
||||
if (aliasList.Index(fName.GetFullPath()) == wxNOT_FOUND)
|
||||
const wxString fullPath{fName.GetFullPath()};
|
||||
if (aliasList.Index(fullPath) == wxNOT_FOUND)
|
||||
return true;
|
||||
|
||||
/* i18n-hint: 'old' is part of a filename used when a file is renamed. */
|
||||
@ -1214,7 +1221,7 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
/* i18n-hint: e.g. Try to go from "mysong.wav" to "mysong-old1.wav". */
|
||||
// Keep trying until we find a filename that doesn't exist.
|
||||
|
||||
wxFileName renamedFileName = fName;
|
||||
wxFileNameWrapper renamedFileName{ fName };
|
||||
int i = 0;
|
||||
do {
|
||||
i++;
|
||||
@ -1227,11 +1234,12 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
// Test creating a file by that name to make sure it will
|
||||
// be possible to do the rename
|
||||
|
||||
wxFile testFile(renamedFileName.GetFullPath(), wxFile::write);
|
||||
const wxString renamedFullPath{ renamedFileName.GetFullPath() };
|
||||
wxFile testFile(renamedFullPath, wxFile::write);
|
||||
if (!testFile.IsOpened()) {
|
||||
{ // need braces to avoid compiler warning about ambiguous else, see the macro
|
||||
wxLogSysError(_("Unable to open/create test file."),
|
||||
renamedFileName.GetFullPath().c_str());
|
||||
renamedFullPath.c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1239,16 +1247,16 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
// Close the file prior to renaming.
|
||||
testFile.Close();
|
||||
|
||||
if (!wxRemoveFile(renamedFileName.GetFullPath())) {
|
||||
if (!wxRemoveFile(renamedFullPath)) {
|
||||
/* i18n-hint: %s is the name of a file.*/
|
||||
{ // need braces to avoid compiler warning about ambiguous else, see the macro
|
||||
wxLogSysError(_("Unable to remove '%s'."),
|
||||
renamedFileName.GetFullPath().c_str());
|
||||
renamedFullPath.c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
wxPrintf(_("Renamed file: %s\n"), renamedFileName.GetFullPath().c_str());
|
||||
wxPrintf(_("Renamed file: %s\n"), renamedFullPath.c_str());
|
||||
|
||||
// Go through our block files and see if any indeed point to
|
||||
// the file we're concerned about. If so, point the block file
|
||||
@ -1263,18 +1271,18 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
// don't worry, we don't rely on this cast unless IsAlias is true
|
||||
AliasBlockFile *ab = (AliasBlockFile*)b;
|
||||
|
||||
// don't worry, we don't rely on this cast unless ISDataAvailable is false
|
||||
// which means that it still needs to access the file.
|
||||
ODDecodeBlockFile *db = (ODDecodeBlockFile*)b;
|
||||
|
||||
if (b->IsAlias() && ab->GetAliasedFileName() == fName) {
|
||||
needToRename = true;
|
||||
|
||||
//ODBlocks access the aliased file on another thread, so we need to pause them before this continues.
|
||||
ab->LockRead();
|
||||
}
|
||||
|
||||
//now for encoded OD blocks (e.g. flac)
|
||||
// don't worry, we don't rely on this cast unless ISDataAvailable is false
|
||||
// which means that it still needs to access the file.
|
||||
ODDecodeBlockFile *db = (ODDecodeBlockFile*)b;
|
||||
if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
|
||||
else if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
|
||||
needToRename = true;
|
||||
|
||||
//ODBlocks access the aliased file on another thread, so we need to pause them before this continues.
|
||||
@ -1285,8 +1293,8 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
}
|
||||
|
||||
if (needToRename) {
|
||||
if (!wxRenameFile(fName.GetFullPath(),
|
||||
renamedFileName.GetFullPath()))
|
||||
if (!wxRenameFile(fullPath,
|
||||
renamedFullPath))
|
||||
{
|
||||
// ACK!!! The renaming was unsuccessful!!!
|
||||
// (This shouldn't happen, since we tried creating a
|
||||
@ -1312,8 +1320,8 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
|
||||
// Print error message and cancel the export
|
||||
wxLogSysError(_("Unable to rename '%s' to '%s'."),
|
||||
fName.GetFullPath().c_str(),
|
||||
renamedFileName.GetFullPath().c_str());
|
||||
fullPath.c_str(),
|
||||
renamedFullPath.c_str());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -1328,13 +1336,13 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
|
||||
if (b->IsAlias() && ab->GetAliasedFileName() == fName)
|
||||
{
|
||||
ab->ChangeAliasedFileName(renamedFileName);
|
||||
ab->ChangeAliasedFileName(std::move(renamedFileName));
|
||||
ab->UnlockRead();
|
||||
wxPrintf(_("Changed block %s to new alias name\n"), b->GetFileName().GetFullName().c_str());
|
||||
|
||||
}
|
||||
if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
|
||||
db->ChangeAudioFile(renamedFileName);
|
||||
else if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
|
||||
db->ChangeAudioFile(std::move(renamedFileName));
|
||||
db->UnlockRead();
|
||||
}
|
||||
++iter;
|
||||
@ -1342,8 +1350,8 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
|
||||
|
||||
}
|
||||
|
||||
aliasList.Remove(fName.GetFullPath());
|
||||
aliasList.Add(renamedFileName.GetFullPath());
|
||||
aliasList.Remove(fullPath);
|
||||
aliasList.Add(renamedFullPath);
|
||||
}
|
||||
|
||||
// Success!!! Either we successfully renamed the file,
|
||||
@ -1479,9 +1487,9 @@ _("Project check of \"%s\" folder \
|
||||
// This is done, eventually, in PCMAliasBlockFile::ReadData()
|
||||
// and ODPCMAliasBlockFile::ReadData, in the stack of b->Recover().
|
||||
// There, if the mAliasedFileName is bad, it zeroes the data.
|
||||
wxFileName dummy;
|
||||
wxFileNameWrapper dummy;
|
||||
dummy.Clear();
|
||||
b->ChangeAliasedFileName(dummy);
|
||||
b->ChangeAliasedFileName(std::move(dummy));
|
||||
b->Recover();
|
||||
nResult = FSCKstatus_CHANGED | FSCKstatus_SAVE_AUP;
|
||||
}
|
||||
@ -1699,7 +1707,7 @@ void DirManager::FindMissingAliasedFiles(
|
||||
BlockFile *b = iter->second;
|
||||
if (b->IsAlias())
|
||||
{
|
||||
wxFileName aliasedFileName = ((AliasBlockFile*)b)->GetAliasedFileName();
|
||||
const wxFileName &aliasedFileName = ((AliasBlockFile*)b)->GetAliasedFileName();
|
||||
wxString aliasedFileFullPath = aliasedFileName.GetFullPath();
|
||||
// wxEmptyString can happen if user already chose to "replace... with silence".
|
||||
if ((aliasedFileFullPath != wxEmptyString) &&
|
||||
@ -1730,13 +1738,13 @@ void DirManager::FindMissingAUFs(
|
||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
wxString key = iter->first;
|
||||
const wxString &key = iter->first;
|
||||
BlockFile *b = iter->second;
|
||||
if (b->IsAlias() && b->IsSummaryAvailable())
|
||||
{
|
||||
/* don't look in hash; that might find files the user moved
|
||||
that the Blockfile abstraction can't find itself */
|
||||
wxFileName fileName = MakeBlockFilePath(key);
|
||||
wxFileNameWrapper fileName{ MakeBlockFilePath(key) };
|
||||
fileName.SetName(key);
|
||||
fileName.SetExt(wxT("auf"));
|
||||
if (!fileName.FileExists())
|
||||
@ -1756,11 +1764,11 @@ void DirManager::FindMissingAUs(
|
||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
wxString key = iter->first;
|
||||
const wxString &key = iter->first;
|
||||
BlockFile *b = iter->second;
|
||||
if (!b->IsAlias())
|
||||
{
|
||||
wxFileName fileName = MakeBlockFilePath(key);
|
||||
wxFileNameWrapper fileName{ MakeBlockFilePath(key) };
|
||||
fileName.SetName(key);
|
||||
fileName.SetExt(wxT("au"));
|
||||
if (!fileName.FileExists())
|
||||
@ -1783,13 +1791,14 @@ void DirManager::FindOrphanBlockFiles(
|
||||
|
||||
for (size_t i = 0; i < filePathArray.GetCount(); i++)
|
||||
{
|
||||
wxFileName fullname = filePathArray[i];
|
||||
const wxFileName &fullname = filePathArray[i];
|
||||
wxString basename = fullname.GetName();
|
||||
const wxString ext{fullname.GetExt()};
|
||||
if ((mBlockFileHash.find(basename) == mBlockFileHash.end()) && // is orphan
|
||||
// Consider only Audacity data files.
|
||||
// Specifically, ignore <branding> JPG and <import> OGG ("Save Compressed Copy").
|
||||
(fullname.GetExt().IsSameAs(wxT("au")) ||
|
||||
fullname.GetExt().IsSameAs(wxT("auf"))))
|
||||
(ext.IsSameAs(wxT("au")) ||
|
||||
ext.IsSameAs(wxT("auf"))))
|
||||
{
|
||||
if (!clipboardDM) {
|
||||
TrackList *clipTracks = AudacityProject::GetClipboardTracks();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "audacity/Types.h"
|
||||
#include "xml/XMLTagHandler.h"
|
||||
#include "wxFileNameWrapper.h"
|
||||
|
||||
class wxHashTable;
|
||||
class BlockArray;
|
||||
@ -94,7 +95,7 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler {
|
||||
bool MoveToNewProjectDirectory(BlockFile *f);
|
||||
bool CopyToNewProjectDirectory(BlockFile *f);
|
||||
|
||||
bool EnsureSafeFilename(wxFileName fName);
|
||||
bool EnsureSafeFilename(const wxFileName &fName);
|
||||
|
||||
void Ref(BlockFile * f);
|
||||
void Deref(BlockFile * f);
|
||||
@ -116,7 +117,7 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler {
|
||||
bool HandleXMLTag(const wxChar *tag, const wxChar **attrs);
|
||||
XMLTagHandler *HandleXMLChild(const wxChar * WXUNUSED(tag)) { return NULL; }
|
||||
void WriteXML(XMLWriter & WXUNUSED(xmlFile)) { wxASSERT(false); } // This class only reads tags.
|
||||
bool AssignFile(wxFileName &filename, const wxString &value, bool check);
|
||||
bool AssignFile(wxFileNameWrapper &filename, const wxString &value, bool check);
|
||||
|
||||
// Clean the temp dir. Note that now where we have auto recovery the temp
|
||||
// dir is not cleaned at start up anymore. But it is cleaned when the
|
||||
@ -168,8 +169,8 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler {
|
||||
|
||||
private:
|
||||
|
||||
wxFileName MakeBlockFileName();
|
||||
wxFileName MakeBlockFilePath(const wxString &value);
|
||||
wxFileNameWrapper MakeBlockFileName();
|
||||
wxFileNameWrapper MakeBlockFilePath(const wxString &value);
|
||||
|
||||
bool MoveOrCopyToNewProjectDirectory(BlockFile *f, bool copy);
|
||||
|
||||
|
@ -248,6 +248,7 @@ audacity_SOURCES = \
|
||||
WaveTrackLocation.h \
|
||||
WrappedType.cpp \
|
||||
WrappedType.h \
|
||||
wxFileNameWrapper.h \
|
||||
commands/AppCommandEvent.cpp \
|
||||
commands/AppCommandEvent.h \
|
||||
commands/BatchEvalCommand.cpp \
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
58
src/wxFileNameWrapper.h
Normal file
58
src/wxFileNameWrapper.h
Normal file
@ -0,0 +1,58 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
wxFileNameWrapper.h
|
||||
|
||||
Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_WXFILENAMEWRAPPER__
|
||||
#define __AUDACITY_WXFILENAMEWRAPPER__
|
||||
|
||||
// The wxFileName does not have a move constructor.
|
||||
// So add one to it, so that it passes around by value more quickly.
|
||||
class wxFileNameWrapper : public wxFileName
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
wxFileNameWrapper(const wxFileName &that)
|
||||
: wxFileName(that)
|
||||
{}
|
||||
|
||||
wxFileNameWrapper() = default;
|
||||
wxFileNameWrapper(const wxFileNameWrapper &that) = default;
|
||||
wxFileNameWrapper &operator= (const wxFileNameWrapper &that) = default;
|
||||
|
||||
void swap(wxFileNameWrapper &that)
|
||||
{
|
||||
if (this != &that) {
|
||||
enum : size_t { Size = sizeof(*this) };
|
||||
// Do it bitwise.
|
||||
// std::aligned_storage<Size>::type buffer;
|
||||
char buffer[Size];
|
||||
memcpy(&buffer, this, Size);
|
||||
memcpy(this, &that, Size);
|
||||
memcpy(&that, &buffer, Size);
|
||||
}
|
||||
}
|
||||
|
||||
// Define move copy and assignment in terms of swap
|
||||
wxFileNameWrapper(wxFileNameWrapper &&that)
|
||||
{
|
||||
swap(that);
|
||||
}
|
||||
|
||||
wxFileNameWrapper &operator= (wxFileNameWrapper &&that)
|
||||
{
|
||||
if (this != &that) {
|
||||
Clear();
|
||||
swap(that);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -440,6 +440,7 @@
|
||||
<ClInclude Include="..\..\..\src\WaveTrackLocation.h" />
|
||||
<ClInclude Include="..\..\..\src\widgets\HelpSystem.h" />
|
||||
<ClInclude Include="..\..\..\src\widgets\NumericTextCtrl.h" />
|
||||
<ClInclude Include="..\..\..\src\wxFileNameWrapper.h" />
|
||||
<ClInclude Include="..\..\configwin.h" />
|
||||
<ClInclude Include="..\..\..\src\Dependencies.h" />
|
||||
<ClInclude Include="..\..\..\src\DeviceManager.h" />
|
||||
|
@ -1723,6 +1723,9 @@
|
||||
<ClInclude Include="..\..\..\src\MemoryX.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\wxFileNameWrapper.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\effects\Equalization48x.h">
|
||||
<Filter>src\effects</Filter>
|
||||
</ClInclude>
|
||||
|
Loading…
x
Reference in New Issue
Block a user