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 1064 of file SqliteSampleBlock.cpp.

1066{
1067 using namespace WaveTrackUtilities;
1069
1070 // Collect ids that survive
1071 using namespace WaveTrackUtilities;
1072 SampleBlockIDSet wontDelete;
1073 auto f = [&](const UndoStackElem &elem) {
1074 if (auto pTracks = UndoTracks::Find(elem))
1075 InspectBlocks(*pTracks, {}, &wontDelete);
1076 };
1077 manager.VisitStates(f, 0, begin);
1078 manager.VisitStates(f, end, manager.GetNumStates());
1079 if (const auto saved = manager.GetSavedState(); saved >= 0)
1080 manager.VisitStates(f, saved, saved + 1);
1081 InspectBlocks(TrackList::Get(project), {}, &wontDelete);
1082
1083 // Collect ids that won't survive (and are not negative pseudo ids)
1084 SampleBlockIDSet seen, mayDelete;
1085 manager.VisitStates([&](const UndoStackElem &elem) {
1086 if (auto pTracks = UndoTracks::Find(elem)) {
1087 InspectBlocks(*pTracks,
1088 [&](SampleBlockConstPtr pBlock){
1089 auto id = pBlock->GetBlockID();
1090 if (id > 0 && !wontDelete.count(id))
1091 mayDelete.insert(id);
1092 },
1093 &seen
1094 );
1095 }
1096 }, begin, end);
1097 return mayDelete.size();
1098}
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 1135 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().