mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-04 17:49:45 +02:00
Use type alias for pointer to BlockFile, which is still a dumb pointer
This commit is contained in:
parent
dc7c4383fc
commit
2ede67be96
@ -338,7 +338,7 @@ bool RecordingRecoveryHandler::HandleXMLTag(const wxChar *tag,
|
||||
BlockArray array;
|
||||
array.resize(1);
|
||||
dirManager->SetLoadingTarget(&array, 0);
|
||||
BlockFile *& blockFile = array[0].f;
|
||||
auto &blockFile = array[0].f;
|
||||
|
||||
if (!dirManager->HandleXMLTag(tag, attrs) || !blockFile)
|
||||
{
|
||||
|
@ -43,6 +43,11 @@ class SummaryInfo {
|
||||
|
||||
|
||||
|
||||
class BlockFile;
|
||||
|
||||
// to do: use shared_ptr instead
|
||||
using BlockFilePtr = BlockFile *;
|
||||
|
||||
class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
||||
public:
|
||||
|
||||
@ -127,7 +132,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(wxFileNameWrapper &&newFileName) = 0;
|
||||
virtual BlockFilePtr Copy(wxFileNameWrapper &&newFileName) = 0;
|
||||
|
||||
virtual wxLongLong GetSpaceUsage() const = 0;
|
||||
|
||||
|
@ -45,9 +45,10 @@
|
||||
WX_DECLARE_HASH_MAP(wxString, AliasedFile *,
|
||||
wxStringHash, wxStringEqual, AliasedFileHash);
|
||||
|
||||
WX_DECLARE_HASH_MAP(BlockFile *, BlockFile *,
|
||||
// These two hash types are used only inside short scopes
|
||||
// so it is safe to key them by plain pointers.
|
||||
WX_DECLARE_HASH_MAP(BlockFile *, BlockFilePtr,
|
||||
wxPointerHash, wxPointerEqual, ReplacedBlockFileHash);
|
||||
|
||||
WX_DECLARE_HASH_MAP(BlockFile *, bool,
|
||||
wxPointerHash, wxPointerEqual, BoolBlockFileHash);
|
||||
|
||||
@ -89,14 +90,15 @@ static void ReplaceBlockFiles(AudacityProject *project,
|
||||
|
||||
int i;
|
||||
for (i = 0; i < (int)blocks.size(); i++) {
|
||||
if (hash.count(blocks[i]->f) > 0) {
|
||||
BlockFile *src = blocks[i]->f;
|
||||
BlockFile *dst = hash[src];
|
||||
auto &f = blocks[i]->f;
|
||||
const auto src = &*f;
|
||||
if (hash.count( src ) > 0) {
|
||||
const auto &dst = hash[src];
|
||||
|
||||
dirManager->Deref(src);
|
||||
dirManager->Ref(dst);
|
||||
|
||||
blocks[i]->f = dst;
|
||||
f = dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,12 +115,12 @@ void FindDependencies(AudacityProject *project,
|
||||
BoolBlockFileHash blockFileHash;
|
||||
|
||||
for (const auto &blockFile : blocks) {
|
||||
BlockFile *f = blockFile->f;
|
||||
if (f->IsAlias() && (blockFileHash.count(f) == 0))
|
||||
const auto &f = blockFile->f;
|
||||
if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
|
||||
{
|
||||
// f is an alias block we have not yet counted.
|
||||
blockFileHash[f] = true; // Don't count the same blockfile twice.
|
||||
AliasBlockFile *aliasBlockFile = static_cast<AliasBlockFile*>(f);
|
||||
blockFileHash[ &*f ] = true; // Don't count the same blockfile twice.
|
||||
auto aliasBlockFile = static_cast<AliasBlockFile*>( &*f );
|
||||
const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
|
||||
|
||||
// In DirManager::ProjectFSCK(), if the user has chosen to
|
||||
@ -183,11 +185,11 @@ static void RemoveDependencies(AudacityProject *project,
|
||||
ReplacedBlockFileHash blockFileHash;
|
||||
wxLongLong completedBytes = 0;
|
||||
for (const auto blockFile : blocks) {
|
||||
BlockFile *f = blockFile->f;
|
||||
if (f->IsAlias() && (blockFileHash.count(f) == 0))
|
||||
const auto &f = blockFile->f;
|
||||
if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
|
||||
{
|
||||
// f is an alias block we have not yet processed.
|
||||
AliasBlockFile *aliasBlockFile = static_cast<AliasBlockFile*>(f);
|
||||
auto aliasBlockFile = static_cast<AliasBlockFile*>( &*f );
|
||||
const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
|
||||
const wxString &fileNameStr = fileName.GetFullPath();
|
||||
|
||||
@ -197,7 +199,7 @@ static void RemoveDependencies(AudacityProject *project,
|
||||
|
||||
// Convert it from an aliased file to an actual file in the project.
|
||||
unsigned int len = aliasBlockFile->GetLength();
|
||||
BlockFile *newBlockFile;
|
||||
BlockFilePtr newBlockFile;
|
||||
{
|
||||
SampleBuffer buffer(len, format);
|
||||
f->ReadData(buffer.ptr(), format, 0, len);
|
||||
@ -206,7 +208,7 @@ static void RemoveDependencies(AudacityProject *project,
|
||||
}
|
||||
|
||||
// Update our hash so we know what block files we've done
|
||||
blockFileHash[f] = newBlockFile;
|
||||
blockFileHash[ &*f ] = newBlockFile;
|
||||
|
||||
// Update the progress bar
|
||||
completedBytes += SAMPLE_SIZE(format) * len;
|
||||
|
@ -447,12 +447,12 @@ bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const
|
||||
int count = 0;
|
||||
while ((iter != mBlockFileHash.end()) && success)
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
|
||||
if (b->IsLocked())
|
||||
success = CopyToNewProjectDirectory(b);
|
||||
success = CopyToNewProjectDirectory( &*b );
|
||||
else{
|
||||
success = MoveToNewProjectDirectory(b);
|
||||
success = MoveToNewProjectDirectory( &*b );
|
||||
}
|
||||
|
||||
progress.Update(count, total);
|
||||
@ -473,8 +473,8 @@ bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const
|
||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
MoveToNewProjectDirectory(b);
|
||||
BlockFilePtr b = iter->second;
|
||||
MoveToNewProjectDirectory(&*b);
|
||||
|
||||
if (count >= 0)
|
||||
progress.Update(count, total);
|
||||
@ -863,7 +863,7 @@ wxFileNameWrapper DirManager::MakeBlockFileName()
|
||||
return std::move(ret);
|
||||
}
|
||||
|
||||
BlockFile *DirManager::NewSimpleBlockFile(
|
||||
BlockFilePtr DirManager::NewSimpleBlockFile(
|
||||
samplePtr sampleData, sampleCount sampleLen,
|
||||
sampleFormat format,
|
||||
bool allowDeferredWrite)
|
||||
@ -880,7 +880,7 @@ BlockFile *DirManager::NewSimpleBlockFile(
|
||||
return newBlockFile;
|
||||
}
|
||||
|
||||
BlockFile *DirManager::NewAliasBlockFile(
|
||||
BlockFilePtr DirManager::NewAliasBlockFile(
|
||||
const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel)
|
||||
{
|
||||
@ -898,7 +898,7 @@ BlockFile *DirManager::NewAliasBlockFile(
|
||||
return newBlockFile;
|
||||
}
|
||||
|
||||
BlockFile *DirManager::NewODAliasBlockFile(
|
||||
BlockFilePtr DirManager::NewODAliasBlockFile(
|
||||
const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel)
|
||||
{
|
||||
@ -915,7 +915,7 @@ BlockFile *DirManager::NewODAliasBlockFile(
|
||||
return newBlockFile;
|
||||
}
|
||||
|
||||
BlockFile *DirManager::NewODDecodeBlockFile(
|
||||
BlockFilePtr DirManager::NewODDecodeBlockFile(
|
||||
const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel, int decodeType)
|
||||
{
|
||||
@ -939,7 +939,10 @@ bool DirManager::ContainsBlockFile(const BlockFile *b) const
|
||||
return false;
|
||||
auto result = b->GetFileName();
|
||||
BlockHash::const_iterator it = mBlockFileHash.find(result.name.GetName());
|
||||
return it != mBlockFileHash.end() && it->second == b;
|
||||
if (it == mBlockFileHash.end())
|
||||
return false;
|
||||
BlockFilePtr ptr = it->second;
|
||||
return ptr && (b == &*ptr);
|
||||
}
|
||||
|
||||
bool DirManager::ContainsBlockFile(const wxString &filepath) const
|
||||
@ -952,7 +955,7 @@ bool DirManager::ContainsBlockFile(const wxString &filepath) const
|
||||
// Adds one to the reference count of the block file,
|
||||
// UNLESS it is "locked", then it makes a NEW copy of
|
||||
// the BlockFile.
|
||||
BlockFile *DirManager::CopyBlockFile(BlockFile *b)
|
||||
BlockFilePtr DirManager::CopyBlockFile(const BlockFilePtr &b)
|
||||
{
|
||||
auto result = b->GetFileName();
|
||||
const auto &fn = result.name;
|
||||
@ -970,7 +973,7 @@ BlockFile *DirManager::CopyBlockFile(BlockFile *b)
|
||||
}
|
||||
|
||||
// Copy the blockfile
|
||||
BlockFile *b2;
|
||||
BlockFilePtr b2;
|
||||
if (!fn.IsOk())
|
||||
// Block files with uninitialized filename (i.e. SilentBlockFile)
|
||||
// just need an in-memory copy.
|
||||
@ -991,7 +994,7 @@ BlockFile *DirManager::CopyBlockFile(BlockFile *b)
|
||||
{
|
||||
if( !wxCopyFile(fn.GetFullPath(),
|
||||
newFile.GetFullPath()) )
|
||||
return NULL;
|
||||
return {};
|
||||
}
|
||||
|
||||
// Done with fn
|
||||
@ -1000,7 +1003,7 @@ BlockFile *DirManager::CopyBlockFile(BlockFile *b)
|
||||
b2 = b->Copy(std::move(newFile));
|
||||
|
||||
if (b2 == NULL)
|
||||
return NULL;
|
||||
return {};
|
||||
|
||||
mBlockFileHash[newName]=b2;
|
||||
aliasList.Add(newPath);
|
||||
@ -1014,9 +1017,9 @@ bool DirManager::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
if( mLoadingTarget == NULL )
|
||||
return false;
|
||||
|
||||
BlockFile* pBlockFile = NULL;
|
||||
BlockFilePtr pBlockFile {};
|
||||
|
||||
BlockFile *&target = mLoadingTarget->at(mLoadingTargetIdx).f;
|
||||
BlockFilePtr &target = mLoadingTarget->at(mLoadingTargetIdx).f;
|
||||
|
||||
if (!wxStricmp(tag, wxT("silentblockfile"))) {
|
||||
// Silent blocks don't actually have a file associated, so
|
||||
@ -1092,20 +1095,19 @@ bool DirManager::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
//
|
||||
|
||||
wxString name = target->GetFileName().name.GetName();
|
||||
BlockFile *retrieved = mBlockFileHash[name];
|
||||
auto &wRetrieved = mBlockFileHash[name];
|
||||
BlockFilePtr retrieved = wRetrieved;
|
||||
if (retrieved) {
|
||||
// Lock it in order to DELETE it safely, i.e. without having
|
||||
// it DELETE the file, too...
|
||||
target->Lock();
|
||||
delete target;
|
||||
|
||||
Ref(retrieved); // Add one to its reference count
|
||||
target = retrieved;
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is a NEW object
|
||||
mBlockFileHash[name] = target;
|
||||
wRetrieved = target;
|
||||
// MakeBlockFileName wasn't used so we must add the directory
|
||||
// balancing information
|
||||
BalanceInfoAdd(name);
|
||||
@ -1284,13 +1286,13 @@ bool DirManager::EnsureSafeFilename(const wxFileName &fName)
|
||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
// don't worry, we don't rely on this cast unless IsAlias is true
|
||||
AliasBlockFile *ab = (AliasBlockFile*)b;
|
||||
auto ab = static_cast< 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;
|
||||
auto db = static_cast< ODDecodeBlockFile * > ( &*b );
|
||||
|
||||
if (b->IsAlias() && ab->GetAliasedFileName() == fName) {
|
||||
needToRename = true;
|
||||
@ -1323,9 +1325,9 @@ bool DirManager::EnsureSafeFilename(const wxFileName &fName)
|
||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
AliasBlockFile *ab = (AliasBlockFile*)b;
|
||||
ODDecodeBlockFile *db = (ODDecodeBlockFile*)b;
|
||||
BlockFilePtr b = iter->second;
|
||||
auto ab = static_cast< AliasBlockFile * > ( &*b );
|
||||
auto db = static_cast< ODDecodeBlockFile * > ( &*b );
|
||||
|
||||
if (b->IsAlias() && (ab->GetAliasedFileName() == fName))
|
||||
ab->UnlockRead();
|
||||
@ -1347,9 +1349,9 @@ bool DirManager::EnsureSafeFilename(const wxFileName &fName)
|
||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
AliasBlockFile *ab = (AliasBlockFile*)b;
|
||||
ODDecodeBlockFile *db = (ODDecodeBlockFile*)b;
|
||||
BlockFilePtr b = iter->second;
|
||||
auto ab = static_cast< AliasBlockFile * > ( &*b );
|
||||
auto db = static_cast< ODDecodeBlockFile * > ( &*b );
|
||||
|
||||
if (b->IsAlias() && ab->GetAliasedFileName() == fName)
|
||||
{
|
||||
@ -1477,11 +1479,12 @@ _("Project check of \"%s\" folder \
|
||||
BlockHash::iterator iter = missingAliasedFileAUFHash.begin();
|
||||
while (iter != missingAliasedFileAUFHash.end())
|
||||
{
|
||||
// This type caste is safe. We checked that it's an alias block file earlier.
|
||||
AliasBlockFile *b = (AliasBlockFile*)iter->second;
|
||||
// This type cast is safe. We checked that it's an alias block file earlier.
|
||||
BlockFilePtr b = iter->second;
|
||||
auto ab = static_cast< AliasBlockFile * > ( &*b );
|
||||
if (action == 1)
|
||||
// Silence error logging for this block in this session.
|
||||
b->SilenceAliasLog();
|
||||
ab->SilenceAliasLog();
|
||||
else if (action == 2)
|
||||
{
|
||||
// silence the blockfiles by yanking the filename
|
||||
@ -1490,8 +1493,8 @@ _("Project check of \"%s\" folder \
|
||||
// There, if the mAliasedFileName is bad, it zeroes the data.
|
||||
wxFileNameWrapper dummy;
|
||||
dummy.Clear();
|
||||
b->ChangeAliasedFileName(std::move(dummy));
|
||||
b->Recover();
|
||||
ab->ChangeAliasedFileName(std::move(dummy));
|
||||
ab->Recover();
|
||||
nResult = FSCKstatus_CHANGED | FSCKstatus_SAVE_AUP;
|
||||
}
|
||||
++iter;
|
||||
@ -1539,7 +1542,7 @@ _("Project check of \"%s\" folder \
|
||||
BlockHash::iterator iter = missingAUFHash.begin();
|
||||
while (iter != missingAUFHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if(action==0){
|
||||
//regenerate from data
|
||||
b->Recover();
|
||||
@ -1598,7 +1601,7 @@ _("Project check of \"%s\" folder \
|
||||
BlockHash::iterator iter = missingAUHash.begin();
|
||||
while (iter != missingAUHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (action == 2)
|
||||
{
|
||||
//regenerate with zeroes
|
||||
@ -1705,10 +1708,11 @@ void DirManager::FindMissingAliasedFiles(
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
wxString key = iter->first; // file name and extension
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (b->IsAlias())
|
||||
{
|
||||
const wxFileName &aliasedFileName = ((AliasBlockFile*)b)->GetAliasedFileName();
|
||||
const wxFileName &aliasedFileName =
|
||||
static_cast< AliasBlockFile* > ( &*b )->GetAliasedFileName();
|
||||
wxString aliasedFileFullPath = aliasedFileName.GetFullPath();
|
||||
// wxEmptyString can happen if user already chose to "replace... with silence".
|
||||
if ((aliasedFileFullPath != wxEmptyString) &&
|
||||
@ -1719,7 +1723,7 @@ void DirManager::FindMissingAliasedFiles(
|
||||
missingAliasedFilePathHash.end()) // Add it only once.
|
||||
// Not actually using the block here, just the path,
|
||||
// so set the block to NULL to create the entry.
|
||||
missingAliasedFilePathHash[aliasedFileFullPath] = NULL;
|
||||
missingAliasedFilePathHash[aliasedFileFullPath] = {};
|
||||
}
|
||||
}
|
||||
++iter;
|
||||
@ -1740,7 +1744,7 @@ void DirManager::FindMissingAUFs(
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
const wxString &key = iter->first;
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (b->IsAlias() && b->IsSummaryAvailable())
|
||||
{
|
||||
/* don't look in hash; that might find files the user moved
|
||||
@ -1766,7 +1770,7 @@ void DirManager::FindMissingAUs(
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
const wxString &key = iter->first;
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (!b->IsAlias())
|
||||
{
|
||||
wxFileNameWrapper fileName{ MakeBlockFilePath(key) };
|
||||
@ -1866,7 +1870,7 @@ void DirManager::FillBlockfilesCache()
|
||||
iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (b->GetNeedFillCache())
|
||||
numNeed++;
|
||||
++iter;
|
||||
@ -1882,7 +1886,7 @@ void DirManager::FillBlockfilesCache()
|
||||
int current = 0;
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (b->GetNeedFillCache() && (GetFreeMemory() > lowMem)) {
|
||||
b->FillCache();
|
||||
}
|
||||
@ -1903,7 +1907,7 @@ void DirManager::WriteCacheToDisk()
|
||||
iter = mBlockFileHash.begin();
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (b->GetNeedWriteCacheToDisk())
|
||||
numNeed++;
|
||||
++iter;
|
||||
@ -1919,7 +1923,7 @@ void DirManager::WriteCacheToDisk()
|
||||
int current = 0;
|
||||
while (iter != mBlockFileHash.end())
|
||||
{
|
||||
BlockFile *b = iter->second;
|
||||
BlockFilePtr b = iter->second;
|
||||
if (b->GetNeedWriteCacheToDisk())
|
||||
{
|
||||
b->WriteCacheToDisk();
|
||||
|
@ -32,7 +32,11 @@ class SequenceTest;
|
||||
#define FSCKstatus_SAVE_AUP 0x4 // used in combination with FSCKstatus_CHANGED
|
||||
|
||||
WX_DECLARE_HASH_MAP(int, int, wxIntegerHash, wxIntegerEqual, DirHash);
|
||||
WX_DECLARE_HASH_MAP(wxString, BlockFile*, wxStringHash, wxStringEqual, BlockHash);
|
||||
|
||||
class BlockFile;
|
||||
using BlockFilePtr = BlockFile *;
|
||||
|
||||
WX_DECLARE_HASH_MAP(wxString, BlockFilePtr, wxStringHash, wxStringEqual, BlockHash);
|
||||
|
||||
wxMemorySize GetFreeMemory();
|
||||
|
||||
@ -56,18 +60,22 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler {
|
||||
|
||||
wxLongLong GetFreeDiskSpace();
|
||||
|
||||
BlockFile *NewSimpleBlockFile(samplePtr sampleData,
|
||||
BlockFilePtr
|
||||
NewSimpleBlockFile(samplePtr sampleData,
|
||||
sampleCount sampleLen,
|
||||
sampleFormat format,
|
||||
bool allowDeferredWrite = false);
|
||||
|
||||
BlockFile *NewAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart,
|
||||
BlockFilePtr
|
||||
NewAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel);
|
||||
|
||||
BlockFile *NewODAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart,
|
||||
BlockFilePtr
|
||||
NewODAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel);
|
||||
|
||||
BlockFile *NewODDecodeBlockFile( const wxString &aliasedFile, sampleCount aliasStart,
|
||||
BlockFilePtr
|
||||
NewODDecodeBlockFile( const wxString &aliasedFile, sampleCount aliasStart,
|
||||
sampleCount aliasLen, int aliasChannel, int decodeType);
|
||||
|
||||
/// Returns true if the blockfile pointed to by b is contained by the DirManager
|
||||
@ -78,7 +86,7 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler {
|
||||
// Adds one to the reference count of the block file,
|
||||
// UNLESS it is "locked", then it makes a NEW copy of
|
||||
// the BlockFile.
|
||||
BlockFile *CopyBlockFile(BlockFile *b);
|
||||
BlockFilePtr CopyBlockFile(const BlockFilePtr &b);
|
||||
|
||||
BlockFile *LoadBlockFile(const wxChar **attrs, sampleFormat format);
|
||||
void SaveBlockFile(BlockFile *f, int depth, FILE *fp);
|
||||
|
@ -176,7 +176,7 @@ bool Sequence::ConvertToSampleFormat(sampleFormat format, bool* pbChanged)
|
||||
for (size_t i = 0, nn = mBlock.size(); i < nn && bSuccess; i++)
|
||||
{
|
||||
SeqBlock &oldSeqBlock = mBlock[i];
|
||||
BlockFile* oldBlockFile = oldSeqBlock.f;
|
||||
const auto &oldBlockFile = oldSeqBlock.f;
|
||||
|
||||
sampleCount len = oldBlockFile->GetLength();
|
||||
|
||||
@ -277,7 +277,7 @@ bool Sequence::GetMinMax(sampleCount start, sampleCount len,
|
||||
{
|
||||
float block0Min, block0Max, block0RMS;
|
||||
const SeqBlock &theBlock = mBlock[block0];
|
||||
BlockFile *const theFile = theBlock.f;
|
||||
const auto &theFile = theBlock.f;
|
||||
theFile->GetMinMax(&block0Min, &block0Max, &block0RMS);
|
||||
|
||||
if (block0Min < min || block0Max > max) {
|
||||
@ -302,7 +302,7 @@ bool Sequence::GetMinMax(sampleCount start, sampleCount len,
|
||||
{
|
||||
float block1Min, block1Max, block1RMS;
|
||||
const SeqBlock &theBlock = mBlock[block1];
|
||||
BlockFile *const theFile = theBlock.f;
|
||||
const auto &theFile = theBlock.f;
|
||||
theFile->GetMinMax(&block1Min, &block1Max, &block1RMS);
|
||||
|
||||
if (block1Min < min || block1Max > max) {
|
||||
@ -351,7 +351,7 @@ bool Sequence::GetRMS(sampleCount start, sampleCount len,
|
||||
for (unsigned b = block0 + 1; b < block1; b++) {
|
||||
float blockMin, blockMax, blockRMS;
|
||||
const SeqBlock &theBlock = mBlock[b];
|
||||
BlockFile *const theFile = theBlock.f;
|
||||
const auto &theFile = theBlock.f;
|
||||
theFile->GetMinMax(&blockMin, &blockMax, &blockRMS);
|
||||
|
||||
const sampleCount fileLen = theFile->GetLength();
|
||||
@ -364,7 +364,7 @@ bool Sequence::GetRMS(sampleCount start, sampleCount len,
|
||||
// If not, we need read some samples and summaries from disk.
|
||||
{
|
||||
const SeqBlock &theBlock = mBlock[block0];
|
||||
BlockFile *const theFile = theBlock.f;
|
||||
const auto &theFile = theBlock.f;
|
||||
s0 = start - theBlock.start;
|
||||
l0 = len;
|
||||
maxl0 = theBlock.start + theFile->GetLength() - start;
|
||||
@ -381,7 +381,7 @@ bool Sequence::GetRMS(sampleCount start, sampleCount len,
|
||||
|
||||
if (block1 > block0) {
|
||||
const SeqBlock &theBlock = mBlock[block1];
|
||||
BlockFile *const theFile = theBlock.f;
|
||||
const auto &theFile = theBlock.f;
|
||||
|
||||
s0 = 0;
|
||||
l0 = (start + len) - theBlock.start;
|
||||
@ -429,7 +429,7 @@ bool Sequence::Copy(sampleCount s0, sampleCount s1, std::unique_ptr<Sequence> &d
|
||||
|
||||
const SeqBlock &block0 = mBlock[b0];
|
||||
if (s0 != block0.start) {
|
||||
BlockFile *const file = block0.f;
|
||||
const auto &file = block0.f;
|
||||
blocklen = std::min(s1, block0.start + file->GetLength()) - s0;
|
||||
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
||||
Get(b0, buffer.ptr(), mSampleFormat, s0, blocklen);
|
||||
@ -446,7 +446,7 @@ bool Sequence::Copy(sampleCount s0, sampleCount s1, std::unique_ptr<Sequence> &d
|
||||
// Do the last block
|
||||
if (b1 > b0) {
|
||||
const SeqBlock &block = mBlock[b1];
|
||||
BlockFile *const file = block.f;
|
||||
const auto &file = block.f;
|
||||
blocklen = (s1 - block.start);
|
||||
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
||||
if (blocklen < file->GetLength()) {
|
||||
@ -547,7 +547,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
mSampleFormat, block,
|
||||
splitPoint, length - splitPoint);
|
||||
|
||||
BlockFile *const file =
|
||||
auto file =
|
||||
mDirManager->NewSimpleBlockFile(buffer.ptr(), largerBlockLen, mSampleFormat);
|
||||
|
||||
mDirManager->Deref(block.f);
|
||||
@ -617,7 +617,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
|
||||
for (i = 2; i < srcNumBlocks - 2; i++) {
|
||||
const SeqBlock &block = srcBlock[i];
|
||||
BlockFile *const file = mDirManager->CopyBlockFile(block.f);
|
||||
auto file = mDirManager->CopyBlockFile(block.f);
|
||||
if (!file) {
|
||||
wxASSERT(false); // TODO: Handle this better, alert the user of failure.
|
||||
return false;
|
||||
@ -676,7 +676,7 @@ bool Sequence::InsertSilence(sampleCount s0, sampleCount len)
|
||||
|
||||
sTrack.mBlock.reserve((len + idealSamples - 1) / idealSamples);
|
||||
|
||||
BlockFile *silentFile = 0;
|
||||
BlockFilePtr silentFile {};
|
||||
if (len >= idealSamples)
|
||||
silentFile = new SilentBlockFile(idealSamples);
|
||||
while (len >= idealSamples) {
|
||||
@ -771,9 +771,9 @@ unsigned int Sequence::GetODFlags()
|
||||
{
|
||||
unsigned int ret = 0;
|
||||
for (unsigned int i = 0; i < mBlock.size(); i++) {
|
||||
BlockFile *const file = mBlock[i].f;
|
||||
const auto &file = mBlock[i].f;
|
||||
if(!file->IsDataAvailable())
|
||||
ret |= (static_cast<ODDecodeBlockFile*>(file))->GetDecodeType();
|
||||
ret |= (static_cast< ODDecodeBlockFile * >( &*file ))->GetDecodeType();
|
||||
else if(!file->IsSummaryAvailable())
|
||||
ret |= ODTask::eODPCMSummary;
|
||||
}
|
||||
@ -1114,7 +1114,7 @@ int Sequence::FindBlock(sampleCount pos) const
|
||||
bool Sequence::Read(samplePtr buffer, sampleFormat format,
|
||||
const SeqBlock &b, sampleCount start, sampleCount len) const
|
||||
{
|
||||
BlockFile *f = b.f;
|
||||
const auto &f = b.f;
|
||||
|
||||
wxASSERT(start >= 0);
|
||||
wxASSERT(start + len <= f->GetLength());
|
||||
@ -1541,7 +1541,8 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
|
||||
);
|
||||
// FIXME: TRAP_ERR This could throw an exception that should(?) be converted to return false.
|
||||
if (blockFileLog)
|
||||
static_cast<SimpleBlockFile*>(newLastBlock.f)->SaveXML(*blockFileLog);
|
||||
static_cast< SimpleBlockFile * >( &*newLastBlock.f )
|
||||
->SaveXML( *blockFileLog );
|
||||
|
||||
mDirManager->Deref(lastBlock.f);
|
||||
lastBlock = newLastBlock;
|
||||
@ -1554,7 +1555,7 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
|
||||
while (len) {
|
||||
const sampleCount idealSamples = GetIdealBlockSize();
|
||||
const sampleCount l = std::min(idealSamples, len);
|
||||
BlockFile *pFile;
|
||||
BlockFilePtr pFile;
|
||||
if (format == mSampleFormat) {
|
||||
pFile = mDirManager->NewSimpleBlockFile(buffer, l, mSampleFormat,
|
||||
blockFileLog != NULL);
|
||||
@ -1567,7 +1568,7 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
|
||||
|
||||
// FIXME: TRAP_ERR This could throw an exception that should(?) be converted to return false.
|
||||
if (blockFileLog)
|
||||
static_cast<SimpleBlockFile*>(pFile)->SaveXML(*blockFileLog);
|
||||
static_cast< SimpleBlockFile * >( &*pFile )->SaveXML( *blockFileLog );
|
||||
|
||||
mBlock.push_back(SeqBlock(pFile, mNumSamples));
|
||||
|
||||
@ -1685,7 +1686,7 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
|
||||
if (!scratch.ptr())
|
||||
scratch.Allocate(scratchSize, mSampleFormat);
|
||||
Read(scratch.ptr(), mSampleFormat, preBlock, 0, preBufferLen);
|
||||
BlockFile *const pFile =
|
||||
auto pFile =
|
||||
mDirManager->NewSimpleBlockFile(scratch.ptr(), preBufferLen, mSampleFormat);
|
||||
|
||||
newBlock.push_back(SeqBlock(pFile, preBlock.start));
|
||||
@ -1736,7 +1737,7 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
|
||||
scratch.Allocate(postBufferLen, mSampleFormat);
|
||||
sampleCount pos = (start + len) - postBlock.start;
|
||||
Read(scratch.ptr(), mSampleFormat, postBlock, pos, postBufferLen);
|
||||
BlockFile *const file =
|
||||
auto file =
|
||||
mDirManager->NewSimpleBlockFile(scratch.ptr(), postBufferLen, mSampleFormat);
|
||||
|
||||
newBlock.push_back(SeqBlock(file, start));
|
||||
@ -1855,7 +1856,7 @@ int Sequence::GetMaxDiskBlockSize()
|
||||
return sMaxDiskBlockSize;
|
||||
}
|
||||
|
||||
void Sequence::AppendBlockFile(BlockFile* blockFile)
|
||||
void Sequence::AppendBlockFile(const BlockFilePtr &blockFile)
|
||||
{
|
||||
// We assume blockFile has the correct ref count already
|
||||
|
||||
|
@ -30,20 +30,22 @@ typedef wxLongLong_t sampleCount; /** < A native 64-bit integer type, because
|
||||
#endif
|
||||
|
||||
class BlockFile;
|
||||
using BlockFilePtr = BlockFile *;
|
||||
|
||||
class DirManager;
|
||||
|
||||
// This is an internal data structure! For advanced use only.
|
||||
class SeqBlock {
|
||||
public:
|
||||
BlockFile * f;
|
||||
BlockFilePtr f;
|
||||
///the sample in the global wavetrack that this block starts at.
|
||||
sampleCount start;
|
||||
|
||||
SeqBlock()
|
||||
: f(NULL), start(0)
|
||||
: f{}, start(0)
|
||||
{}
|
||||
|
||||
SeqBlock(BlockFile *f_, sampleCount start_)
|
||||
SeqBlock(const BlockFilePtr &f_, sampleCount start_)
|
||||
: f(f_), start(start_)
|
||||
{}
|
||||
|
||||
@ -123,7 +125,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{
|
||||
// be registered within the dir manager hash. This is the case
|
||||
// when the blockfile is created using DirManager::NewSimpleBlockFile or
|
||||
// loaded from an XML file via DirManager::HandleXMLTag
|
||||
void AppendBlockFile(BlockFile* blockFile);
|
||||
void AppendBlockFile(const BlockFilePtr &blockFile);
|
||||
|
||||
bool SetSilence(sampleCount s0, sampleCount len);
|
||||
bool InsertSilence(sampleCount s0, sampleCount len);
|
||||
|
@ -100,17 +100,17 @@ void UndoManager::CalculateSpaceUsage()
|
||||
BlockArray *blocks = clip->GetSequenceBlockArray();
|
||||
for (const auto &block : *blocks)
|
||||
{
|
||||
BlockFile *file = block.f;
|
||||
const auto &file = block.f;
|
||||
|
||||
// Accumulate space used by the file if the file didn't exist
|
||||
// in the previous level
|
||||
if (prev->count(file) == 0 && cur->count(file) == 0)
|
||||
if (prev->count( &*file ) == 0 && cur->count( &*file ) == 0)
|
||||
{
|
||||
space[i] += file->GetSpaceUsage().GetValue();
|
||||
}
|
||||
|
||||
// Add file to current set
|
||||
cur->insert(file);
|
||||
cur->insert( &*file );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ LegacyAliasBlockFile::~LegacyAliasBlockFile()
|
||||
/// the summary data to a NEW file.
|
||||
///
|
||||
/// @param newFileName The filename to copy the summary data to.
|
||||
BlockFile *LegacyAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
|
||||
BlockFilePtr LegacyAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
|
||||
{
|
||||
BlockFile *newBlockFile =
|
||||
new LegacyAliasBlockFile(std::move(newFileName),
|
||||
@ -83,7 +83,7 @@ void LegacyAliasBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *LegacyAliasBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs)
|
||||
BlockFilePtr LegacyAliasBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs)
|
||||
{
|
||||
wxFileNameWrapper summaryFileName;
|
||||
wxFileNameWrapper aliasFileName;
|
||||
|
@ -32,10 +32,10 @@ class LegacyAliasBlockFile final : public PCMAliasBlockFile
|
||||
virtual ~LegacyAliasBlockFile();
|
||||
|
||||
void SaveXML(XMLWriter &xmlFile) override;
|
||||
BlockFile *Copy(wxFileNameWrapper &&fileName) override;
|
||||
BlockFilePtr Copy(wxFileNameWrapper &&fileName) override;
|
||||
void Recover() override;
|
||||
|
||||
static BlockFile *BuildFromXML(const wxString &projDir, const wxChar **attrs);
|
||||
static BlockFilePtr BuildFromXML(const wxString &projDir, const wxChar **attrs);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -294,7 +294,7 @@ void LegacyBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
/// static
|
||||
BlockFile *LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs,
|
||||
BlockFilePtr LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs,
|
||||
sampleCount len, sampleFormat format)
|
||||
{
|
||||
wxFileNameWrapper fileName;
|
||||
@ -334,7 +334,7 @@ BlockFile *LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar *
|
||||
/// 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(wxFileNameWrapper &&newFileName)
|
||||
BlockFilePtr LegacyBlockFile::Copy(wxFileNameWrapper &&newFileName)
|
||||
{
|
||||
return new LegacyBlockFile(std::move(newFileName),
|
||||
mFormat,
|
||||
|
@ -54,13 +54,13 @@ class LegacyBlockFile final : public BlockFile {
|
||||
sampleCount start, sampleCount len) const override;
|
||||
|
||||
/// Create a NEW block file identical to this one
|
||||
BlockFile *Copy(wxFileNameWrapper &&newFileName) override;
|
||||
BlockFilePtr Copy(wxFileNameWrapper &&newFileName) override;
|
||||
/// Write an XML representation of this file
|
||||
void SaveXML(XMLWriter &xmlFile) override;
|
||||
wxLongLong GetSpaceUsage() const override;
|
||||
void Recover() override;
|
||||
|
||||
static BlockFile *BuildFromXML(const wxString &dir, const wxChar **attrs,
|
||||
static BlockFilePtr BuildFromXML(const wxString &dir, const wxChar **attrs,
|
||||
sampleCount len,
|
||||
sampleFormat format);
|
||||
|
||||
|
@ -158,9 +158,9 @@ 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(wxFileNameWrapper &&newFileName)
|
||||
BlockFilePtr ODDecodeBlockFile::Copy(wxFileNameWrapper &&newFileName)
|
||||
{
|
||||
BlockFile *newBlockFile;
|
||||
BlockFilePtr newBlockFile;
|
||||
|
||||
//mAliasedFile can change so we lock readdatamutex, which is responsible for it.
|
||||
LockRead();
|
||||
@ -222,7 +222,7 @@ void ODDecodeBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
BlockFilePtr ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
wxFileNameWrapper summaryFileName;
|
||||
wxFileNameWrapper audioFileName;
|
||||
|
@ -77,13 +77,13 @@ class ODDecodeBlockFile final : public SimpleBlockFile
|
||||
|
||||
|
||||
///Makes NEW ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability
|
||||
BlockFile *Copy(wxFileNameWrapper &&fileName) override;
|
||||
BlockFilePtr Copy(wxFileNameWrapper &&fileName) override;
|
||||
|
||||
///Saves as xml ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability
|
||||
void SaveXML(XMLWriter &xmlFile) override;
|
||||
|
||||
///Reconstructs from XML a ODPCMAliasBlockFile and reschedules it for OD loading
|
||||
static BlockFile *BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
static BlockFilePtr BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
|
||||
///Writes the summary file if summary data is available
|
||||
void Recover(void) override;
|
||||
|
@ -216,9 +216,9 @@ 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(wxFileNameWrapper &&newFileName)
|
||||
BlockFilePtr ODPCMAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
|
||||
{
|
||||
BlockFile *newBlockFile;
|
||||
BlockFilePtr newBlockFile;
|
||||
|
||||
//mAliasedFile can change so we lock readdatamutex, which is responsible for it.
|
||||
LockRead();
|
||||
@ -290,7 +290,7 @@ void ODPCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
BlockFilePtr ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
wxFileNameWrapper summaryFileName;
|
||||
wxFileNameWrapper aliasFileName;
|
||||
|
@ -75,13 +75,13 @@ 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(wxFileNameWrapper &&fileName) override;
|
||||
BlockFilePtr Copy(wxFileNameWrapper &&fileName) override;
|
||||
|
||||
///Saves as xml ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability
|
||||
void SaveXML(XMLWriter &xmlFile) override;
|
||||
|
||||
///Reconstructs from XML a ODPCMAliasBlockFile and reschedules it for OD loading
|
||||
static BlockFile *BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
static BlockFilePtr BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
|
||||
///Writes the summary file if summary data is available
|
||||
void Recover(void) override;
|
||||
|
@ -150,7 +150,7 @@ 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(wxFileNameWrapper &&newFileName)
|
||||
BlockFilePtr PCMAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
|
||||
{
|
||||
BlockFile *newBlockFile = new PCMAliasBlockFile(std::move(newFileName),
|
||||
wxFileNameWrapper{mAliasedFileName}, mAliasStart,
|
||||
@ -179,7 +179,7 @@ void PCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *PCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
BlockFilePtr PCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
wxFileNameWrapper summaryFileName;
|
||||
wxFileNameWrapper aliasFileName;
|
||||
|
@ -41,10 +41,10 @@ class PCMAliasBlockFile /* not final */ : public AliasBlockFile
|
||||
sampleCount start, sampleCount len) const override;
|
||||
|
||||
void SaveXML(XMLWriter &xmlFile) override;
|
||||
BlockFile *Copy(wxFileNameWrapper &&fileName) override;
|
||||
BlockFilePtr Copy(wxFileNameWrapper &&fileName) override;
|
||||
void Recover() override;
|
||||
|
||||
static BlockFile *BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
static BlockFilePtr BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -51,7 +51,7 @@ void SilentBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
/// static
|
||||
BlockFile *SilentBlockFile::BuildFromXML(DirManager & WXUNUSED(dm), const wxChar **attrs)
|
||||
BlockFilePtr SilentBlockFile::BuildFromXML(DirManager & WXUNUSED(dm), const wxChar **attrs)
|
||||
{
|
||||
long nValue;
|
||||
sampleCount len = 0;
|
||||
@ -75,7 +75,7 @@ BlockFile *SilentBlockFile::BuildFromXML(DirManager & WXUNUSED(dm), const wxChar
|
||||
}
|
||||
|
||||
/// Create a copy of this BlockFile
|
||||
BlockFile *SilentBlockFile::Copy(wxFileNameWrapper &&)
|
||||
BlockFilePtr SilentBlockFile::Copy(wxFileNameWrapper &&)
|
||||
{
|
||||
BlockFile *newBlockFile = new SilentBlockFile(mLen);
|
||||
|
||||
|
@ -39,13 +39,13 @@ class SilentBlockFile final : public BlockFile {
|
||||
sampleCount start, sampleCount len) const override;
|
||||
|
||||
/// Create a NEW block file identical to this one
|
||||
BlockFile *Copy(wxFileNameWrapper &&newFileName) override;
|
||||
BlockFilePtr Copy(wxFileNameWrapper &&newFileName) override;
|
||||
/// Write an XML representation of this file
|
||||
void SaveXML(XMLWriter &xmlFile) override;
|
||||
wxLongLong GetSpaceUsage() const override;
|
||||
void Recover() override { };
|
||||
|
||||
static BlockFile *BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
static BlockFilePtr BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -492,7 +492,7 @@ void SimpleBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
/// static
|
||||
BlockFile *SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
BlockFilePtr SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
wxFileNameWrapper fileName;
|
||||
float min = 0.0f, max = 0.0f, rms = 0.0f;
|
||||
@ -538,7 +538,7 @@ BlockFile *SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
/// 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(wxFileNameWrapper &&newFileName)
|
||||
BlockFilePtr SimpleBlockFile::Copy(wxFileNameWrapper &&newFileName)
|
||||
{
|
||||
BlockFile *newBlockFile = new SimpleBlockFile(std::move(newFileName), mLen,
|
||||
mMin, mMax, mRMS);
|
||||
|
@ -68,14 +68,14 @@ 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(wxFileNameWrapper &&newFileName) override;
|
||||
BlockFilePtr Copy(wxFileNameWrapper &&newFileName) override;
|
||||
/// Write an XML representation of this file
|
||||
void SaveXML(XMLWriter &xmlFile) override;
|
||||
|
||||
wxLongLong GetSpaceUsage() const override;
|
||||
void Recover() override;
|
||||
|
||||
static BlockFile *BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
static BlockFilePtr BuildFromXML(DirManager &dm, const wxChar **attrs);
|
||||
|
||||
bool GetNeedWriteCacheToDisk() override;
|
||||
void WriteCacheToDisk() override;
|
||||
|
@ -66,7 +66,6 @@ void ODComputeSummaryTask::DoSomeInternal()
|
||||
return;
|
||||
}
|
||||
|
||||
ODPCMAliasBlockFile* bf;
|
||||
sampleCount blockStartSample = 0;
|
||||
sampleCount blockEndSample = 0;
|
||||
bool success =false;
|
||||
@ -74,7 +73,7 @@ void ODComputeSummaryTask::DoSomeInternal()
|
||||
mBlockFilesMutex.Lock();
|
||||
for(size_t i=0; i < mWaveTracks.size() && mBlockFiles.size();i++)
|
||||
{
|
||||
bf = mBlockFiles[0];
|
||||
const auto &bf = mBlockFiles[0];
|
||||
|
||||
//first check to see if the ref count is at least 2. It should have one
|
||||
//from when we added it to this instance's mBlockFiles array, and one from
|
||||
@ -202,7 +201,7 @@ void ODComputeSummaryTask::Update()
|
||||
{
|
||||
//if there is data but no summary, this blockfile needs summarizing.
|
||||
SeqBlock &block = (*blocks)[i];
|
||||
BlockFile *const file = block.f;
|
||||
const auto &file = block.f;
|
||||
if(file->IsDataAvailable() && !file->IsSummaryAvailable())
|
||||
{
|
||||
file->Ref();
|
||||
|
@ -42,7 +42,6 @@ void ODDecodeTask::DoSomeInternal()
|
||||
return;
|
||||
}
|
||||
|
||||
ODDecodeBlockFile* bf;
|
||||
ODFileDecoder* decoder;
|
||||
sampleCount blockStartSample = 0;
|
||||
sampleCount blockEndSample = 0;
|
||||
@ -50,7 +49,7 @@ void ODDecodeTask::DoSomeInternal()
|
||||
|
||||
for(size_t i=0; i < mWaveTracks.size() && mBlockFiles.size();i++)
|
||||
{
|
||||
bf = mBlockFiles[0];
|
||||
const auto &bf = mBlockFiles[0];
|
||||
|
||||
int ret = 1;
|
||||
|
||||
@ -64,7 +63,7 @@ void ODDecodeTask::DoSomeInternal()
|
||||
//which the dirmanager::EnsureSafeFilename also does.
|
||||
bf->LockRead();
|
||||
//Get the decoder. If the file was moved, we need to create another one and init it.
|
||||
decoder=GetOrCreateMatchingFileDecoder(bf);
|
||||
decoder = GetOrCreateMatchingFileDecoder( &*bf );
|
||||
if(!decoder->IsInitialized())
|
||||
decoder->Init();
|
||||
bf->SetODFileDecoder(decoder);
|
||||
|
Loading…
x
Reference in New Issue
Block a user