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

Access BlockFile::mFileName without copying, with proper multithreading cautions

This commit is contained in:
Paul Licameli
2016-04-17 11:42:33 -04:00
parent 94cf94718e
commit 3d102a3390
8 changed files with 65 additions and 32 deletions

View File

@@ -369,13 +369,9 @@ void ODDecodeBlockFile::SetFileName(wxFileNameWrapper &&name)
}
///sets the file name the summary info will be saved in. threadsafe.
wxFileName ODDecodeBlockFile::GetFileName() const
auto ODDecodeBlockFile::GetFileName() const -> GetFileNameResult
{
wxFileName name;
mFileNameMutex.Lock();
name = mFileName;
mFileNameMutex.Unlock();
return name;
return { mFileName, ODLocker{ &mFileNameMutex } };
}
/// A thread-safe version of CalcSummary. BlockFile::CalcSummary

View File

@@ -133,7 +133,7 @@ class ODDecodeBlockFile final : public SimpleBlockFile
///sets the file name the summary info will be saved in. threadsafe.
void SetFileName(wxFileNameWrapper &&name) override;
wxFileName GetFileName() const override;
GetFileNameResult GetFileName() const override;
/// Prevents a read on other threads of the encoded audio file.
void LockRead() const override;

View File

@@ -381,13 +381,9 @@ void ODPCMAliasBlockFile::SetFileName(wxFileNameWrapper &&name)
}
///sets the file name the summary info will be saved in. threadsafe.
wxFileName ODPCMAliasBlockFile::GetFileName() const
auto ODPCMAliasBlockFile::GetFileName() const -> GetFileNameResult
{
wxFileName name;
mFileNameMutex.Lock();
name = mFileName;
mFileNameMutex.Unlock();
return name;
return { mFileName, ODLocker{ &mFileNameMutex } };
}
/// Write the summary to disk, using the derived ReadData() to get the data

View File

@@ -125,7 +125,7 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile
///sets the file name the summary info will be saved in. threadsafe.
void SetFileName(wxFileNameWrapper &&name) override;
wxFileName GetFileName() const override;
GetFileNameResult GetFileName() const override;
//when the file closes, it locks the blockfiles, but only conditionally.
// It calls this so we can check if it has been saved before.