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 "UndoTracks.h"
#include "WaveTrack.h"
#include "WaveTrackUtilities.h"
#include "SentryHelper.h"
#include <wx/log.h>
#include <mutex>
Include dependency graph for SqliteSampleBlock.cpp:

Go to the source code of this file.

Classes

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

Functions

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

Variables

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 
)
static

Just to find a denominator for a progress indicator.

This estimate procedure should in fact be exact

Definition at line 1066 of file SqliteSampleBlock.cpp.

1068{
1069 using namespace WaveTrackUtilities;
1071
1072 // Collect ids that survive
1073 using namespace WaveTrackUtilities;
1074 SampleBlockIDSet wontDelete;
1075 auto f = [&](const UndoStackElem &elem) {
1076 if (auto pTracks = UndoTracks::Find(elem))
1077 InspectBlocks(*pTracks, {}, &wontDelete);
1078 };
1079 manager.VisitStates(f, 0, begin);
1080 manager.VisitStates(f, end, manager.GetNumStates());
1081 if (const auto saved = manager.GetSavedState(); saved >= 0)
1082 manager.VisitStates(f, saved, saved + 1);
1083 InspectBlocks(TrackList::Get(project), {}, &wontDelete);
1084
1085 // Collect ids that won't survive (and are not negative pseudo ids)
1086 SampleBlockIDSet seen, mayDelete;
1087 manager.VisitStates([&](const UndoStackElem &elem) {
1088 if (auto pTracks = UndoTracks::Find(elem)) {
1089 InspectBlocks(*pTracks,
1090 [&](SampleBlockConstPtr pBlock){
1091 auto id = pBlock->GetBlockID();
1092 if (id > 0 && !wontDelete.count(id))
1093 mayDelete.insert(id);
1094 },
1095 &seen
1096 );
1097 }
1098 }, begin, end);
1099 return mayDelete.size();
1100}
std::unordered_set< SampleBlockID > SampleBlockIDSet
Definition: CloudSyncDTO.h:27
static const AttachedProjectObjects::RegisteredFactory manager
std::shared_ptr< const SampleBlock > SampleBlockConstPtr
Definition: SampleBlock.h:29
const auto project
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
TRACK_API TrackList * Find(const UndoStackElem &state)
Definition: UndoTracks.cpp:47
WAVE_TRACK_API void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs=nullptr)
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101
Holds one item with description and time range for the UndoManager.
Definition: UndoManager.h:117

References details::begin(), details::end(), UndoTracks::Find(), UndoManager::Get(), TrackList::Get(), WaveTrackUtilities::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 1137 of file SqliteSampleBlock.cpp.

◆ sSilentBlocks

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

Definition at line 143 of file SqliteSampleBlock.cpp.

Referenced by SqliteSampleBlockFactory::DoCreateSilent().