1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

AUP3: Better space usage calculations

Several improvements in determining how much actual disk space a
sampleblock uses. This allows us to provide how much space will
be recovered when using File -> Compact Project.

In addition, the History window now provides better space estimates.
This commit is contained in:
Leland Lucius
2020-08-01 04:25:42 -05:00
parent 59c3b360b7
commit 8943494f8a
6 changed files with 282 additions and 49 deletions

View File

@@ -12,6 +12,7 @@ Paul Licameli -- split from SampleBlock.cpp and SampleBlock.h
#include <sqlite3.h>
#include "DBConnection.h"
#include "ProjectFileIO.h"
#include "SampleFormat.h"
#include "xml/XMLTagHandler.h"
@@ -454,8 +455,7 @@ MinMaxRMS SqliteSampleBlock::DoGetMinMaxRMS() const
size_t SqliteSampleBlock::GetSpaceUsage() const
{
// Not an exact number, but close enough
return mSummary256Bytes + mSummary64kBytes + mSampleBytes;
return ProjectFileIO::GetDiskUsage(Conn(), mBlockID);
}
size_t SqliteSampleBlock::GetBlob(void *dest,
@@ -868,10 +868,16 @@ void SqliteSampleBlock::CalcSummary()
}
// Inject our database implementation at startup
static struct Injector { Injector() {
// Do this some time before the first project is created
(void) SampleBlockFactory::RegisterFactoryFactory(
[]( AudacityProject &project ){
return std::make_shared<SqliteSampleBlockFactory>( project ); }
);
} } injector;
static struct Injector
{
Injector()
{
// Do this some time before the first project is created
(void) SampleBlockFactory::RegisterFactoryFactory(
[]( AudacityProject &project )
{
return std::make_shared<SqliteSampleBlockFactory>( project );
}
);
}
} injector;