Audacity 3.2.0
Classes | Functions | Variables
SqliteSampleBlock.cpp File Reference
#include <float.h>
#include <sqlite3.h>
#include "BasicUI.h"
#include "DBConnection.h"
#include "ProjectFileIO.h"
#include "SampleFormat.h"
#include "AudioSegmentSampleView.h"
#include "XMLTagHandler.h"
#include "SampleBlock.h"
#include "UndoManager.h"
#include "WaveTrack.h"
#include "SentryHelper.h"
#include <wx/log.h>
#include <mutex>
Include dependency graph for SqliteSampleBlock.cpp:

Go to the source code of this file.


class  SqliteSampleBlock
 Implementation of SampleBlock using Sqlite database. More...
class  SqliteSampleBlockFactory
 Implementation of SampleBlockFactory using Sqlite database. More...


static size_t EstimateRemovedBlocks (AudacityProject &project, size_t begin, size_t end)
 Just to find a denominator for a progress indicator. More...


static std::map< SampleBlockID, std::shared_ptr< SqliteSampleBlock > > sSilentBlocks
static SampleBlockFactory::Factory::Scope scope

Function Documentation

◆ EstimateRemovedBlocks()

static size_t EstimateRemovedBlocks ( AudacityProject project,
size_t  begin,
size_t  end 

Just to find a denominator for a progress indicator.

This estimate procedure should in fact be exact

Definition at line 1062 of file SqliteSampleBlock.cpp.

1067 // Collect ids that survive
1068 SampleBlockIDSet wontDelete;
1069 auto f = [&](const UndoStackElem &elem) {
1070 if (auto pTracks = TrackList::FindUndoTracks(elem))
1071 InspectBlocks(*pTracks, {}, &wontDelete);
1072 };
1073 manager.VisitStates(f, 0, begin);
1074 manager.VisitStates(f, end, manager.GetNumStates());
1075 if (const auto saved = manager.GetSavedState(); saved >= 0)
1076 manager.VisitStates(f, saved, saved + 1);
1077 InspectBlocks(TrackList::Get(project), {}, &wontDelete);
1079 // Collect ids that won't survive (and are not negative pseudo ids)
1080 SampleBlockIDSet seen, mayDelete;
1081 manager.VisitStates([&](const UndoStackElem &elem) {
1082 if (auto pTracks = TrackList::FindUndoTracks(elem)) {
1083 InspectBlocks(*pTracks,
1084 [&](const SampleBlock &block){
1085 auto id = block.GetBlockID();
1086 if (id > 0 && !wontDelete.count(id))
1087 mayDelete.insert(id);
1088 },
1089 &seen
1090 );
1091 }
1092 }, begin, end);
1093 return mayDelete.size();
static const AttachedProjectObjects::RegisteredFactory manager
const auto project
void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs)
Definition: WaveTrack.cpp:4499
std::unordered_set< SampleBlockID > SampleBlockIDSet
Definition: WaveTrack.h:1259
Abstract class allows access to contents of a block of sound samples, serialization as XML,...
Definition: SampleBlock.h:46
virtual SampleBlockID GetBlockID() const =0
static TrackList * FindUndoTracks(const UndoStackElem &state)
Definition: Track.cpp:1406
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150
Holds one item with description and time range for the UndoManager.
Definition: UndoManager.h:117

References PackedArray::begin(), PackedArray::end(), TrackList::FindUndoTracks(), UndoManager::Get(), TrackList::Get(), SampleBlock::GetBlockID(), InspectBlocks(), manager, and project.

Referenced by SqliteSampleBlockFactory::OnBeginPurge().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ scope

Initial value:
return std::make_shared<SqliteSampleBlockFactory>( project );
} }
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90

Definition at line 1131 of file SqliteSampleBlock.cpp.

◆ sSilentBlocks

std::map< SampleBlockID, std::shared_ptr<SqliteSampleBlock> > sSilentBlocks

Definition at line 141 of file SqliteSampleBlock.cpp.

Referenced by SqliteSampleBlockFactory::DoCreateSilent().