1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-28 06:29:24 +02:00

Merge remote-tracking branch 'upstream/master' into darkaudacity

This commit is contained in:
James Crook 2016-08-17 22:27:43 +01:00
commit 13e8a81276

View File

@ -455,20 +455,17 @@ bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const
while ((iter != mBlockFileHash.end()) && success) while ((iter != mBlockFileHash.end()) && success)
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (b->IsLocked())
success = CopyToNewProjectDirectory( &*b );
else{
success = MoveToNewProjectDirectory( &*b );
}
if (!b) progress.Update(count, total);
continue; count++;
if (b->IsLocked())
success = CopyToNewProjectDirectory( &*b );
else{
success = MoveToNewProjectDirectory( &*b );
} }
progress.Update(count, total);
++iter; ++iter;
count++;
} }
// in case there are any nulls // in case there are any nulls
@ -487,17 +484,14 @@ bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
MoveToNewProjectDirectory(&*b);
if (!b) if (count >= 0)
continue; progress.Update(count, total);
count--;
MoveToNewProjectDirectory(&*b); }
if (count >= 0)
progress.Update(count, total);
++iter; ++iter;
count--;
} }
this->projFull = oldFull; this->projFull = oldFull;
@ -1319,31 +1313,28 @@ bool DirManager::EnsureSafeFilename(const wxFileName &fName)
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
// don't worry, we don't rely on this cast unless IsAlias is true
auto ab = static_cast< AliasBlockFile * > ( &*b );
if (!b) // don't worry, we don't rely on this cast unless ISDataAvailable is false
continue; // which means that it still needs to access the file.
auto db = static_cast< ODDecodeBlockFile * > ( &*b );
// don't worry, we don't rely on this cast unless IsAlias is true if (b->IsAlias() && ab->GetAliasedFileName() == fName) {
auto ab = static_cast< AliasBlockFile * > ( &*b ); needToRename = true;
// don't worry, we don't rely on this cast unless ISDataAvailable is false //ODBlocks access the aliased file on another thread, so we need to pause them before this continues.
// which means that it still needs to access the file. ab->LockRead();
auto db = static_cast< ODDecodeBlockFile * > ( &*b ); }
//now for encoded OD blocks (e.g. flac)
else if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
needToRename = true;
if (b->IsAlias() && ab->GetAliasedFileName() == fName) { //ODBlocks access the aliased file on another thread, so we need to pause them before this continues.
needToRename = true; db->LockRead();
}
//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)
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.
db->LockRead();
}
++iter; ++iter;
} }
@ -1362,18 +1353,15 @@ bool DirManager::EnsureSafeFilename(const wxFileName &fName)
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
auto ab = static_cast< AliasBlockFile * > ( &*b );
auto db = static_cast< ODDecodeBlockFile * > ( &*b );
if (!b) if (b->IsAlias() && (ab->GetAliasedFileName() == fName))
continue; ab->UnlockRead();
if (!b->IsDataAvailable() && (db->GetEncodedAudioFilename() == fName))
auto ab = static_cast< AliasBlockFile * > ( &*b ); db->UnlockRead();
auto db = static_cast< ODDecodeBlockFile * > ( &*b ); }
if (b->IsAlias() && (ab->GetAliasedFileName() == fName))
ab->UnlockRead();
if (!b->IsDataAvailable() && (db->GetEncodedAudioFilename() == fName))
db->UnlockRead();
++iter; ++iter;
} }
@ -1390,24 +1378,22 @@ bool DirManager::EnsureSafeFilename(const wxFileName &fName)
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
auto ab = static_cast< AliasBlockFile * > ( &*b );
auto db = static_cast< ODDecodeBlockFile * > ( &*b );
if (!b) if (b->IsAlias() && ab->GetAliasedFileName() == fName)
continue; {
ab->ChangeAliasedFileName(wxFileNameWrapper{ renamedFileName });
ab->UnlockRead();
wxPrintf(_("Changed block %s to new alias name\n"),
b->GetFileName().name.GetFullName().c_str());
auto ab = static_cast< AliasBlockFile * > ( &*b ); }
auto db = static_cast< ODDecodeBlockFile * > ( &*b ); else if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
db->ChangeAudioFile(wxFileNameWrapper{ renamedFileName });
if (b->IsAlias() && ab->GetAliasedFileName() == fName) db->UnlockRead();
{ }
ab->ChangeAliasedFileName(wxFileNameWrapper{ renamedFileName });
ab->UnlockRead();
wxPrintf(_("Changed block %s to new alias name\n"),
b->GetFileName().name.GetFullName().c_str());
}
else if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
db->ChangeAudioFile(wxFileNameWrapper{ renamedFileName });
db->UnlockRead();
} }
++iter; ++iter;
} }
@ -1525,26 +1511,24 @@ _("Project check of \"%s\" folder \
{ {
// This type cast is safe. We checked that it's an alias block file earlier. // This type cast is safe. We checked that it's an alias block file earlier.
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
wxASSERT(b); wxASSERT(b);
if (!b) if (b) {
continue; auto ab = static_cast< AliasBlockFile * > ( &*b );
if (action == 1)
auto ab = static_cast< AliasBlockFile * > ( &*b ); // Silence error logging for this block in this session.
if (action == 1) ab->SilenceAliasLog();
// Silence error logging for this block in this session. else if (action == 2)
ab->SilenceAliasLog(); {
else if (action == 2) // silence the blockfiles by yanking the filename
{ // This is done, eventually, in PCMAliasBlockFile::ReadData()
// silence the blockfiles by yanking the filename // and ODPCMAliasBlockFile::ReadData, in the stack of b->Recover().
// This is done, eventually, in PCMAliasBlockFile::ReadData() // There, if the mAliasedFileName is bad, it zeroes the data.
// and ODPCMAliasBlockFile::ReadData, in the stack of b->Recover(). wxFileNameWrapper dummy;
// There, if the mAliasedFileName is bad, it zeroes the data. dummy.Clear();
wxFileNameWrapper dummy; ab->ChangeAliasedFileName(std::move(dummy));
dummy.Clear(); ab->Recover();
ab->ChangeAliasedFileName(std::move(dummy)); nResult = FSCKstatus_CHANGED | FSCKstatus_SAVE_AUP;
ab->Recover(); }
nResult = FSCKstatus_CHANGED | FSCKstatus_SAVE_AUP;
} }
++iter; ++iter;
} }
@ -1592,18 +1576,16 @@ _("Project check of \"%s\" folder \
while (iter != missingAUFHash.end()) while (iter != missingAUFHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
wxASSERT(b); wxASSERT(b);
if (!b) if (b) {
continue; if(action==0){
//regenerate from data
if(action==0){ b->Recover();
//regenerate from data nResult |= FSCKstatus_CHANGED;
b->Recover(); }else if (action==1){
nResult |= FSCKstatus_CHANGED; // Silence error logging for this block in this session.
}else if (action==1){ b->SilenceLog();
// Silence error logging for this block in this session. }
b->SilenceLog();
} }
++iter; ++iter;
} }
@ -1656,19 +1638,17 @@ _("Project check of \"%s\" folder \
while (iter != missingAUHash.end()) while (iter != missingAUHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
wxASSERT(b); wxASSERT(b);
if (!b) if (b) {
continue; if (action == 2)
{
if (action == 2) //regenerate with zeroes
{ b->Recover();
//regenerate with zeroes nResult = FSCKstatus_CHANGED;
b->Recover(); }
nResult = FSCKstatus_CHANGED; else if (action == 1)
b->SilenceLog();
} }
else if (action == 1)
b->SilenceLog();
++iter; ++iter;
} }
if ((action == 2) && bAutoRecoverMode) if ((action == 2) && bAutoRecoverMode)
@ -1768,25 +1748,23 @@ void DirManager::FindMissingAliasedFiles(
{ {
wxString key = iter->first; // file name and extension wxString key = iter->first; // file name and extension
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (!b) if (b->IsAlias())
continue;
if (b->IsAlias())
{
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) &&
!aliasedFileName.FileExists())
{ {
missingAliasedFileAUFHash[key] = b; const wxFileName &aliasedFileName =
if (missingAliasedFilePathHash.find(aliasedFileFullPath) == static_cast< AliasBlockFile* > ( &*b )->GetAliasedFileName();
missingAliasedFilePathHash.end()) // Add it only once. wxString aliasedFileFullPath = aliasedFileName.GetFullPath();
// Not actually using the block here, just the path, // wxEmptyString can happen if user already chose to "replace... with silence".
// so set the block to NULL to create the entry. if ((aliasedFileFullPath != wxEmptyString) &&
missingAliasedFilePathHash[aliasedFileFullPath] = {}; !aliasedFileName.FileExists())
{
missingAliasedFileAUFHash[key] = b;
if (missingAliasedFilePathHash.find(aliasedFileFullPath) ==
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] = {};
}
} }
} }
++iter; ++iter;
@ -1808,22 +1786,20 @@ void DirManager::FindMissingAUFs(
{ {
const wxString &key = iter->first; const wxString &key = iter->first;
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (!b) if (b->IsAlias() && b->IsSummaryAvailable())
continue;
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 */
wxFileNameWrapper fileName{ MakeBlockFilePath(key) };
fileName.SetName(key);
fileName.SetExt(wxT("auf"));
if (!fileName.FileExists())
{ {
missingAUFHash[key] = b; /* don't look in hash; that might find files the user moved
wxLogWarning(_("Missing alias (.auf) block file: '%s'"), that the Blockfile abstraction can't find itself */
fileName.GetFullPath().c_str()); wxFileNameWrapper fileName{ MakeBlockFilePath(key) };
fileName.SetName(key);
fileName.SetExt(wxT("auf"));
if (!fileName.FileExists())
{
missingAUFHash[key] = b;
wxLogWarning(_("Missing alias (.auf) block file: '%s'"),
fileName.GetFullPath().c_str());
}
} }
} }
++iter; ++iter;
@ -1838,20 +1814,18 @@ void DirManager::FindMissingAUs(
{ {
const wxString &key = iter->first; const wxString &key = iter->first;
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (!b) if (!b->IsAlias())
continue;
if (!b->IsAlias())
{
wxFileNameWrapper fileName{ MakeBlockFilePath(key) };
fileName.SetName(key);
fileName.SetExt(wxT("au"));
if (!fileName.FileExists())
{ {
missingAUHash[key] = b; wxFileNameWrapper fileName{ MakeBlockFilePath(key) };
wxLogWarning(_("Missing data block file: '%s'"), fileName.SetName(key);
fileName.GetFullPath().c_str()); fileName.SetExt(wxT("au"));
if (!fileName.FileExists())
{
missingAUHash[key] = b;
wxLogWarning(_("Missing data block file: '%s'"),
fileName.GetFullPath().c_str());
}
} }
} }
++iter; ++iter;
@ -1942,12 +1916,10 @@ void DirManager::FillBlockfilesCache()
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (!b) if (b->GetNeedFillCache())
continue; numNeed++;
}
if (b->GetNeedFillCache())
numNeed++;
++iter; ++iter;
} }
@ -1962,18 +1934,16 @@ void DirManager::FillBlockfilesCache()
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (b->GetNeedFillCache() && (GetFreeMemory() > lowMem)) {
b->FillCache();
}
if (!b) if (!progress.Update(current, numNeed))
continue; break; // user cancelled progress dialog, stop caching
current++;
if (b->GetNeedFillCache() && (GetFreeMemory() > lowMem)) {
b->FillCache();
} }
if (!progress.Update(current, numNeed))
break; // user cancelled progress dialog, stop caching
++iter; ++iter;
current++;
} }
#endif // DEPRECATED_AUDIO_CACHE #endif // DEPRECATED_AUDIO_CACHE
} }
@ -1987,12 +1957,10 @@ void DirManager::WriteCacheToDisk()
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (!b) if (b->GetNeedWriteCacheToDisk())
continue; numNeed++;
}
if (b->GetNeedWriteCacheToDisk())
numNeed++;
++iter; ++iter;
} }
@ -2007,17 +1975,15 @@ void DirManager::WriteCacheToDisk()
while (iter != mBlockFileHash.end()) while (iter != mBlockFileHash.end())
{ {
BlockFilePtr b = iter->second.lock(); BlockFilePtr b = iter->second.lock();
if (b) {
if (!b) if (b->GetNeedWriteCacheToDisk())
continue; {
b->WriteCacheToDisk();
if (b->GetNeedWriteCacheToDisk()) progress.Update(current, numNeed);
{ }
b->WriteCacheToDisk(); current++;
progress.Update(current, numNeed);
} }
++iter; ++iter;
current++;
} }
} }