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 "XMLTagHandler.h"
#include "SampleBlock.h"
#include "UndoManager.h"
#include "WaveTrack.h"
#include "SentryHelper.h"
#include <wx/log.h>
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 1016 of file SqliteSampleBlock.cpp.

1019 auto &manager = UndoManager::Get(project);
1021 // Collect ids that survive
1022 SampleBlockIDSet wontDelete;
1023 auto f = [&](const UndoStackElem &elem){
1024 InspectBlocks(*elem.state.tracks, {}, &wontDelete);
1025 };
1026 manager.VisitStates(f, 0, begin);
1027 manager.VisitStates(f, end, manager.GetNumStates());
1028 if (const auto saved = manager.GetSavedState(); saved >= 0)
1029 manager.VisitStates(f, saved, saved + 1);
1030 InspectBlocks(TrackList::Get(project), {}, &wontDelete);
1032 // Collect ids that won't survive (and are not negative pseudo ids)
1033 SampleBlockIDSet seen, mayDelete;
1034 manager.VisitStates( [&](const UndoStackElem &elem){
1035 auto &tracks = *elem.state.tracks;
1036 InspectBlocks(tracks, [&]( const SampleBlock &block ){
1037 auto id = block.GetBlockID();
1038 if ( id > 0 && !wontDelete.count( id ) )
1039 mayDelete.insert( id );
1040 },
1041 &seen);
1042 }, begin, end );
1043 return mayDelete.size();
static const AttachedProjectObjects::RegisteredFactory manager
void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs)
Definition: WaveTrack.cpp:2778
std::unordered_set< SampleBlockID > SampleBlockIDSet
Definition: WaveTrack.h:600
Abstract class allows access to contents of a block of sound samples, serialization as XML,...
Definition: SampleBlock.h:44
virtual SampleBlockID GetBlockID() const =0
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:67
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:127
UndoState state
Definition: UndoManager.h:140
std::shared_ptr< TrackList > tracks
Definition: UndoManager.h:123

References PackedArray::begin(), PackedArray::end(), UndoManager::Get(), TrackList::Get(), SampleBlock::GetBlockID(), InspectBlocks(), manager, UndoStackElem::state, and UndoState::tracks.

Referenced by SqliteSampleBlockFactory::OnBeginPurge().

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

Variable Documentation

◆ scope

SampleBlockFactory::Factory::Scope scope
Initial value:
{ []( AudacityProject &project )
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 1081 of file SqliteSampleBlock.cpp.

◆ sSilentBlocks

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

Definition at line 132 of file SqliteSampleBlock.cpp.

Referenced by SqliteSampleBlockFactory::DoCreateSilent().