mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-25 00:30:07 +02:00
AUP3: Provides relief from slow shutdown
This is a hack to fix the long delay at Audacity shutdown after editing large files and tossing the results (not saving).
This commit is contained in:
parent
127696879d
commit
48287e9b0d
@ -87,13 +87,12 @@ static const char *ProjectFileSchema =
|
||||
");"
|
||||
""
|
||||
// CREATE SQL sampleblocks
|
||||
// 'samples' are fixed size blocks of float32 numbers.
|
||||
// 'samples' are fixed size blocks of int16, int32 or float32 numbers.
|
||||
// The blocks may be partially empty.
|
||||
// The quantity of valid data in the blocks is
|
||||
// provided in the project XML.
|
||||
//
|
||||
// sampleformat was once used to specify whether floats
|
||||
// or ints for the data, but is no longer used.
|
||||
// sampleformat specifies the format of the samples stored.
|
||||
//
|
||||
// blockID is a 64 bit number.
|
||||
//
|
||||
@ -198,6 +197,8 @@ ProjectFileIO::ProjectFileIO(AudacityProject &)
|
||||
mModified = false;
|
||||
mTemporary = true;
|
||||
|
||||
mBypass = false;
|
||||
|
||||
UpdatePrefs();
|
||||
}
|
||||
|
||||
@ -1275,13 +1276,13 @@ const TranslatableString & ProjectFileIO::GetLibraryError() const
|
||||
return mLibraryError;
|
||||
}
|
||||
|
||||
void ProjectFileIO::SetError(const TranslatableString & msg)
|
||||
void ProjectFileIO::SetError(const TranslatableString &msg)
|
||||
{
|
||||
mLastError = msg;
|
||||
mLibraryError = {};
|
||||
}
|
||||
|
||||
void ProjectFileIO::SetDBError(const TranslatableString & msg)
|
||||
void ProjectFileIO::SetDBError(const TranslatableString &msg)
|
||||
{
|
||||
mLastError = msg;
|
||||
if (mDB)
|
||||
@ -1289,3 +1290,14 @@ void ProjectFileIO::SetDBError(const TranslatableString & msg)
|
||||
mLibraryError = Verbatim(sqlite3_errmsg(mDB));
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectFileIO::Bypass(bool bypass)
|
||||
{
|
||||
mBypass = bypass;
|
||||
}
|
||||
|
||||
bool ProjectFileIO::ShouldBypass()
|
||||
{
|
||||
return mBypass;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ Paul Licameli split from AudacityProject.h
|
||||
struct sqlite3;
|
||||
|
||||
class AudacityProject;
|
||||
class AutoCommitTransaction;
|
||||
class AutoSaveFile;
|
||||
class SqliteSampleBlock;
|
||||
class WaveTrack;
|
||||
@ -46,8 +47,6 @@ public:
|
||||
ProjectFileIO &operator=( const ProjectFileIO & ) PROHIBITED;
|
||||
~ProjectFileIO();
|
||||
|
||||
bool WarnOfLegacyFile( );
|
||||
|
||||
// It seems odd to put this method in this class, but the results do depend
|
||||
// on what is discovered while opening the file, such as whether it is a
|
||||
// recovery file
|
||||
@ -76,8 +75,23 @@ public:
|
||||
|
||||
wxLongLong GetFreeDiskSpace();
|
||||
|
||||
const TranslatableString & GetLastError() const;
|
||||
const TranslatableString & GetLibraryError() const;
|
||||
const TranslatableString &GetLastError() const;
|
||||
const TranslatableString &GetLibraryError() const;
|
||||
|
||||
// Provides a means to bypass "DELETE"s at shutdown if the database
|
||||
// is just going to be deleted anyway. This prevents a noticable
|
||||
// delay caused by SampleBlocks being deleted when the Sequences that
|
||||
// own them are deleted.
|
||||
//
|
||||
// This is definitely hackage territory. While this ability would
|
||||
// still be needed, I think handling it in a DB abstraction might be
|
||||
// a tad bit cleaner.
|
||||
//
|
||||
// For it's usage, see:
|
||||
// SqliteSampleBlock::~SqliteSampleBlock()
|
||||
// ProjectManager::OnCloseWindow()
|
||||
void Bypass(bool bypass);
|
||||
bool ShouldBypass();
|
||||
|
||||
private:
|
||||
// XMLTagHandler callback methods
|
||||
@ -128,6 +142,9 @@ private:
|
||||
// Is this project still a temporary/unsaved project
|
||||
bool mTemporary;
|
||||
|
||||
// Bypass transactions if database will be deleted after close
|
||||
bool mBypass;
|
||||
|
||||
sqlite3 *mDB;
|
||||
FilePath mDBPath;
|
||||
TranslatableString mLastError;
|
||||
|
@ -672,6 +672,9 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
|
||||
}
|
||||
}
|
||||
|
||||
// See ProjectFileIO::Bypass() for a description
|
||||
projectFileIO.Bypass(true);
|
||||
|
||||
#ifdef __WXMAC__
|
||||
// Fix bug apparently introduced into 2.1.2 because of wxWidgets 3:
|
||||
// closing a project that was made full-screen (as by clicking the green dot
|
||||
|
@ -283,7 +283,8 @@ SqliteSampleBlock::SqliteSampleBlock(AudacityProject *project)
|
||||
|
||||
SqliteSampleBlock::~SqliteSampleBlock()
|
||||
{
|
||||
if (mRefCnt == 0)
|
||||
// See ProjectFileIO::Bypass() for a description of mIO.mBypass
|
||||
if (mRefCnt == 0 && !mIO.ShouldBypass())
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
@ -320,9 +321,9 @@ size_t SqliteSampleBlock::GetSampleCount() const
|
||||
}
|
||||
|
||||
size_t SqliteSampleBlock::GetSamples(samplePtr dest,
|
||||
sampleFormat destformat,
|
||||
size_t sampleoffset,
|
||||
size_t numsamples)
|
||||
sampleFormat destformat,
|
||||
size_t sampleoffset,
|
||||
size_t numsamples)
|
||||
{
|
||||
return GetBlob(dest,
|
||||
destformat,
|
||||
@ -333,8 +334,8 @@ size_t SqliteSampleBlock::GetSamples(samplePtr dest,
|
||||
}
|
||||
|
||||
bool SqliteSampleBlock::SetSamples(samplePtr src,
|
||||
size_t numsamples,
|
||||
sampleFormat srcformat)
|
||||
size_t numsamples,
|
||||
sampleFormat srcformat)
|
||||
{
|
||||
mSampleFormat = srcformat;
|
||||
|
||||
@ -365,24 +366,24 @@ bool SqliteSampleBlock::SetSilent(size_t numsamples, sampleFormat srcformat)
|
||||
}
|
||||
|
||||
bool SqliteSampleBlock::GetSummary256(float *dest,
|
||||
size_t frameoffset,
|
||||
size_t numframes)
|
||||
size_t frameoffset,
|
||||
size_t numframes)
|
||||
{
|
||||
return GetSummary(dest, frameoffset, numframes, "summary256", mSummary256Bytes);
|
||||
}
|
||||
|
||||
bool SqliteSampleBlock::GetSummary64k(float *dest,
|
||||
size_t frameoffset,
|
||||
size_t numframes)
|
||||
size_t frameoffset,
|
||||
size_t numframes)
|
||||
{
|
||||
return GetSummary(dest, frameoffset, numframes, "summary64k", mSummary64kBytes);
|
||||
}
|
||||
|
||||
bool SqliteSampleBlock::GetSummary(float *dest,
|
||||
size_t frameoffset,
|
||||
size_t numframes,
|
||||
const char *srccolumn,
|
||||
size_t srcbytes)
|
||||
size_t frameoffset,
|
||||
size_t numframes,
|
||||
const char *srccolumn,
|
||||
size_t srcbytes)
|
||||
{
|
||||
return GetBlob(dest,
|
||||
floatSample,
|
||||
@ -472,11 +473,11 @@ size_t SqliteSampleBlock::GetSpaceUsage() const
|
||||
}
|
||||
|
||||
size_t SqliteSampleBlock::GetBlob(void *dest,
|
||||
sampleFormat destformat,
|
||||
const char *srccolumn,
|
||||
sampleFormat srcformat,
|
||||
size_t srcoffset,
|
||||
size_t srcbytes)
|
||||
sampleFormat destformat,
|
||||
const char *srccolumn,
|
||||
sampleFormat srcformat,
|
||||
size_t srcoffset,
|
||||
size_t srcbytes)
|
||||
{
|
||||
auto db = mIO.DB();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user