Audacity 3.2.0
|
Implementation of SampleBlock using Sqlite database. More...
Public Types | |
using | Sizes = std::pair< size_t, size_t > |
Numbers of bytes needed for 256 and for 64k summaries. More... | |
Public Member Functions | |
BlockSampleView | GetFloatSampleView (bool mayThrow) override |
SqliteSampleBlock (const std::shared_ptr< SqliteSampleBlockFactory > &pFactory) | |
~SqliteSampleBlock () override | |
void | CloseLock () noexcept override |
void | SetSamples (constSamplePtr src, size_t numsamples, sampleFormat srcformat) |
void | Commit (Sizes sizes) |
void | Delete () |
SampleBlockID | GetBlockID () const override |
size_t | DoGetSamples (samplePtr dest, sampleFormat destformat, size_t sampleoffset, size_t numsamples) override |
sampleFormat | GetSampleFormat () const override |
size_t | GetSampleCount () const override |
bool | GetSummary256 (float *dest, size_t frameoffset, size_t numframes) override |
Non-throwing, should fill with zeroes on failure. More... | |
bool | GetSummary64k (float *dest, size_t frameoffset, size_t numframes) override |
Non-throwing, should fill with zeroes on failure. More... | |
double | GetSumMin () const |
double | GetSumMax () const |
double | GetSumRms () const |
MinMaxRMS | DoGetMinMaxRMS (size_t start, size_t len) override |
Gets extreme values for the specified region. More... | |
MinMaxRMS | DoGetMinMaxRMS () const override |
Gets extreme values for the entire block. More... | |
size_t | GetSpaceUsage () const override |
void | SaveXML (XMLWriter &xmlFile) override |
Public Member Functions inherited from SampleBlock | |
virtual | ~SampleBlock () |
virtual void | CloseLock () noexcept=0 |
virtual SampleBlockID | GetBlockID () const =0 |
size_t | GetSamples (samplePtr dest, sampleFormat destformat, size_t sampleoffset, size_t numsamples, bool mayThrow=true) |
virtual BlockSampleView | GetFloatSampleView (bool mayThrow)=0 |
virtual sampleFormat | GetSampleFormat () const =0 |
virtual size_t | GetSampleCount () const =0 |
virtual bool | GetSummary256 (float *dest, size_t frameoffset, size_t numframes)=0 |
Non-throwing, should fill with zeroes on failure. More... | |
virtual bool | GetSummary64k (float *dest, size_t frameoffset, size_t numframes)=0 |
Non-throwing, should fill with zeroes on failure. More... | |
MinMaxRMS | GetMinMaxRMS (size_t start, size_t len, bool mayThrow=true) |
Gets extreme values for the specified region. More... | |
MinMaxRMS | GetMinMaxRMS (bool mayThrow=true) const |
Gets extreme values for the entire block. More... | |
virtual size_t | GetSpaceUsage () const =0 |
virtual void | SaveXML (XMLWriter &xmlFile)=0 |
Private Types | |
enum | { fields = 3 , bytesPerFrame = fields * sizeof(float) } |
Private Member Functions | |
bool | IsSilent () const |
void | Load (SampleBlockID sbid) |
bool | GetSummary (float *dest, size_t frameoffset, size_t numframes, DBConnection::StatementID id, const char *sql) |
size_t | GetBlob (void *dest, sampleFormat destformat, sqlite3_stmt *stmt, sampleFormat srcformat, size_t srcoffset, size_t srcbytes) |
Sizes | SetSizes (size_t numsamples, sampleFormat srcformat) |
void | CalcSummary (Sizes sizes) |
DBConnection * | Conn () const |
This must never be called for silent blocks. More... | |
sqlite3 * | DB () const |
Private Attributes | |
std::weak_ptr< std::vector< float > > | mCache |
std::mutex | mCacheMutex |
friend | SqliteSampleBlockFactory |
const std::shared_ptr< SqliteSampleBlockFactory > | mpFactory |
bool | mValid { false } |
bool | mLocked = false |
SampleBlockID | mBlockID { 0 } |
ArrayOf< char > | mSamples |
size_t | mSampleBytes |
size_t | mSampleCount |
sampleFormat | mSampleFormat |
ArrayOf< char > | mSummary256 |
ArrayOf< char > | mSummary64k |
double | mSumMin |
double | mSumMax |
double | mSumRms |
Additional Inherited Members | |
virtual size_t | DoGetSamples (samplePtr dest, sampleFormat destformat, size_t sampleoffset, size_t numsamples)=0 |
virtual MinMaxRMS | DoGetMinMaxRMS (size_t start, size_t len)=0 |
virtual MinMaxRMS | DoGetMinMaxRMS () const =0 |
Implementation of SampleBlock using Sqlite database.
Definition at line 35 of file SqliteSampleBlock.cpp.
using SqliteSampleBlock::Sizes = std::pair< size_t, size_t > |
Numbers of bytes needed for 256 and for 64k summaries.
Definition at line 55 of file SqliteSampleBlock.cpp.
|
private |
|
explicit |
Definition at line 334 of file SqliteSampleBlock.cpp.
References floatSample, mSampleBytes, mSampleCount, mSampleFormat, mSumMax, mSumMin, and mSumRms.
|
override |
Definition at line 347 of file SqliteSampleBlock.cpp.
References Conn(), Delete(), GuardedCall(), IsSilent(), mLocked, and mpFactory.
|
private |
Calculates summary block data describing this sample data.
This method also has the side effect of setting the mSumMin, mSumMax, and mSumRms members of this class.
Definition at line 909 of file SqliteSampleBlock.cpp.
References bytesPerFrame, fields, floatSample, min(), mSampleCount, mSampleFormat, mSamples, mSummary256, mSummary64k, mSumMax, mSumMin, mSumRms, ArrayOf< X >::reinit(), SamplesToFloats(), staffpad::audio::simd::sqrt(), and wxT().
Referenced by SetSamples().
|
overridevirtualnoexcept |
void SqliteSampleBlock::Commit | ( | Sizes | sizes | ) |
Definition at line 770 of file SqliteSampleBlock.cpp.
References ADD_EXCEPTION_CONTEXT, Conn(), DB(), DBConnection::InsertSampleBlock, mBlockID, mCache, mCacheMutex, mSampleBytes, mSampleFormat, mSamples, mSummary256, mSummary64k, mSumMax, mSumMin, mSumRms, mValid, DBConnection::Prepare(), DBConnection::ThrowException(), and wxT().
Referenced by SetSamples().
|
private |
This must never be called for silent blocks.
Definition at line 377 of file SqliteSampleBlock.cpp.
References Internal, mpFactory, and XO().
Referenced by Commit(), DB(), Delete(), DoGetSamples(), GetBlob(), GetSpaceUsage(), GetSummary(), Load(), and ~SqliteSampleBlock().
|
inlineprivate |
Definition at line 110 of file SqliteSampleBlock.cpp.
References Conn(), and DBConnection::DB().
Referenced by Commit(), Delete(), GetBlob(), and Load().
void SqliteSampleBlock::Delete | ( | ) |
Definition at line 841 of file SqliteSampleBlock.cpp.
References ADD_EXCEPTION_CONTEXT, Conn(), DB(), DBConnection::DeleteSampleBlock, IsSilent(), mBlockID, DBConnection::Prepare(), DBConnection::ThrowException(), and wxT().
Referenced by ~SqliteSampleBlock().
|
overridevirtual |
Gets extreme values for the entire block.
Retrieves the minimum, maximum, and maximum RMS of this entire block. This is faster than the other GetMinMax function since these values are already computed.
Implements SampleBlock.
Definition at line 565 of file SqliteSampleBlock.cpp.
|
overridevirtual |
Gets extreme values for the specified region.
Retrieves the minimum, maximum, and maximum RMS of the specified sample data in this block.
start | The offset in this block where the region should begin |
len | The number of samples to include in the region |
Implements SampleBlock.
Definition at line 518 of file SqliteSampleBlock.cpp.
References DoGetSamples(), floatSample, IsSilent(), Load(), mBlockID, min(), mSampleCount, mValid, SampleBuffer::ptr(), and staffpad::audio::simd::sqrt().
|
overridevirtual |
Implements SampleBlock.
Definition at line 415 of file SqliteSampleBlock.cpp.
References Conn(), GetBlob(), DBConnection::GetSamples, IsSilent(), mSampleFormat, DBConnection::Prepare(), SAMPLE_SIZE, and size.
Referenced by DoGetMinMaxRMS(), and GetFloatSampleView().
|
private |
Definition at line 578 of file SqliteSampleBlock.cpp.
References ADD_EXCEPTION_CONTEXT, Conn(), CopySamples(), DB(), floatSample, IsSilent(), Load(), mBlockID, min(), mValid, SAMPLE_SIZE, DBConnection::ThrowException(), and wxT().
Referenced by DoGetSamples(), and GetSummary().
|
overridevirtual |
|
overridevirtual |
Implements SampleBlock.
Definition at line 301 of file SqliteSampleBlock.cpp.
References DoGetSamples(), floatSample, mCache, mCacheMutex, and mSampleCount.
|
overridevirtual |
Implements SampleBlock.
Definition at line 410 of file SqliteSampleBlock.cpp.
References mSampleCount.
|
overridevirtual |
Implements SampleBlock.
Definition at line 405 of file SqliteSampleBlock.cpp.
References mSampleFormat.
|
overridevirtual |
Implements SampleBlock.
Definition at line 570 of file SqliteSampleBlock.cpp.
References Conn(), ProjectFileIO::GetDiskUsage(), IsSilent(), and mBlockID.
|
private |
Definition at line 467 of file SqliteSampleBlock.cpp.
References Conn(), fields, floatSample, GetBlob(), IsSilent(), DBConnection::Prepare(), and SAMPLE_SIZE.
Referenced by GetSummary256(), and GetSummary64k().
|
overridevirtual |
Non-throwing, should fill with zeroes on failure.
Implements SampleBlock.
Definition at line 451 of file SqliteSampleBlock.cpp.
References GetSummary(), and DBConnection::GetSummary256.
|
overridevirtual |
Non-throwing, should fill with zeroes on failure.
Implements SampleBlock.
Definition at line 459 of file SqliteSampleBlock.cpp.
References GetSummary(), and DBConnection::GetSummary64k.
double SqliteSampleBlock::GetSumMax | ( | ) | const |
Definition at line 503 of file SqliteSampleBlock.cpp.
References mSumMax.
double SqliteSampleBlock::GetSumMin | ( | ) | const |
Definition at line 498 of file SqliteSampleBlock.cpp.
References mSumMin.
double SqliteSampleBlock::GetSumRms | ( | ) | const |
Definition at line 508 of file SqliteSampleBlock.cpp.
References mSumRms.
|
inlineprivate |
Definition at line 85 of file SqliteSampleBlock.cpp.
References mBlockID.
Referenced by Delete(), DoGetMinMaxRMS(), DoGetSamples(), GetBlob(), GetSpaceUsage(), GetSummary(), and ~SqliteSampleBlock().
|
private |
Definition at line 702 of file SqliteSampleBlock.cpp.
References ADD_EXCEPTION_CONTEXT, Conn(), DB(), DBConnection::LoadSampleBlock, mBlockID, mSampleBytes, mSampleCount, mSampleFormat, mSumMax, mSumMin, mSumRms, mValid, DBConnection::Prepare(), SAMPLE_SIZE, DBConnection::ThrowException(), and wxT().
Referenced by DoGetMinMaxRMS(), and GetBlob().
|
overridevirtual |
Implements SampleBlock.
Definition at line 887 of file SqliteSampleBlock.cpp.
References mBlockID, XMLWriter::WriteAttr(), and wxT().
void SqliteSampleBlock::SetSamples | ( | constSamplePtr | src, |
size_t | numsamples, | ||
sampleFormat | srcformat | ||
) |
Definition at line 438 of file SqliteSampleBlock.cpp.
References CalcSummary(), Commit(), mSampleBytes, mSamples, ArrayOf< X >::reinit(), and SetSizes().
|
private |
Definition at line 892 of file SqliteSampleBlock.cpp.
References SAMPLE_SIZE.
Referenced by SetSamples().
|
private |
Definition at line 121 of file SqliteSampleBlock.cpp.
Referenced by Commit(), Delete(), DoGetMinMaxRMS(), GetBlob(), GetBlockID(), GetSpaceUsage(), IsSilent(), Load(), and SaveXML().
|
private |
Definition at line 41 of file SqliteSampleBlock.cpp.
Referenced by Commit(), and GetFloatSampleView().
|
private |
Definition at line 42 of file SqliteSampleBlock.cpp.
Referenced by Commit(), and GetFloatSampleView().
|
private |
Definition at line 119 of file SqliteSampleBlock.cpp.
Referenced by CloseLock(), and ~SqliteSampleBlock().
|
private |
Definition at line 117 of file SqliteSampleBlock.cpp.
Referenced by Conn(), and ~SqliteSampleBlock().
|
private |
Definition at line 124 of file SqliteSampleBlock.cpp.
Referenced by Commit(), Load(), SetSamples(), and SqliteSampleBlock().
|
private |
Definition at line 125 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), DoGetMinMaxRMS(), GetFloatSampleView(), GetSampleCount(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 126 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetSamples(), GetSampleFormat(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 123 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), and SetSamples().
|
private |
Definition at line 128 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), and Commit().
|
private |
Definition at line 129 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), and Commit().
|
private |
Definition at line 131 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetMinMaxRMS(), GetSumMax(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 130 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetMinMaxRMS(), GetSumMin(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 132 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetMinMaxRMS(), GetSumRms(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 118 of file SqliteSampleBlock.cpp.
Referenced by Commit(), DoGetMinMaxRMS(), GetBlob(), and Load().
|
private |
Definition at line 115 of file SqliteSampleBlock.cpp.