mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-07 12:12:23 +01:00
Manage block files with std::shared_ptr, BlockHash stores weak_ptr
This commit is contained in:
@@ -101,7 +101,6 @@ ArrayOf<char> BlockFile::fullSummary;
|
||||
/// @param samples The number of samples this BlockFile contains.
|
||||
BlockFile::BlockFile(wxFileNameWrapper &&fileName, sampleCount samples):
|
||||
mLockCount(0),
|
||||
mRefCount(1),
|
||||
mFileName(std::move(fileName)),
|
||||
mLen(samples),
|
||||
mSummaryInfo(samples)
|
||||
@@ -165,28 +164,6 @@ bool BlockFile::IsLocked()
|
||||
return mLockCount > 0;
|
||||
}
|
||||
|
||||
/// Increases the reference count of this block by one. Only
|
||||
/// DirManager should call this method.
|
||||
void BlockFile::Ref() const
|
||||
{
|
||||
mRefCount++;
|
||||
BLOCKFILE_DEBUG_OUTPUT("Ref", mRefCount);
|
||||
}
|
||||
|
||||
/// Decreases the reference count of this block by one. If this
|
||||
/// causes the count to become zero, deletes the associated disk
|
||||
/// file and deletes this object
|
||||
bool BlockFile::Deref() const
|
||||
{
|
||||
mRefCount--;
|
||||
BLOCKFILE_DEBUG_OUTPUT("Deref", mRefCount);
|
||||
if (mRefCount <= 0) {
|
||||
delete this;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Get a buffer containing a summary block describing this sample
|
||||
/// data. This must be called by derived classes when they
|
||||
/// are constructed, to allow them to construct their summary data,
|
||||
|
||||
Reference in New Issue
Block a user