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 |
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 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 33 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 53 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 GlobalHook< DeletionCallback, void(const SampleBlock &) >::Call(), Conn(), Delete(), GuardedCall(), IsSilent(), and mLocked.
|
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 907 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 768 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 375 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 108 of file SqliteSampleBlock.cpp.
References Conn(), and DBConnection::DB().
Referenced by Commit(), Delete(), GetBlob(), and Load().
void SqliteSampleBlock::Delete | ( | ) |
Definition at line 839 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 563 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 516 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 413 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 576 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 408 of file SqliteSampleBlock.cpp.
References mSampleCount.
sampleFormat SqliteSampleBlock::GetSampleFormat | ( | ) | const |
Definition at line 403 of file SqliteSampleBlock.cpp.
References mSampleFormat.
|
overridevirtual |
Implements SampleBlock.
Definition at line 568 of file SqliteSampleBlock.cpp.
References Conn(), ProjectFileIO::GetDiskUsage(), IsSilent(), and mBlockID.
|
private |
Definition at line 465 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 449 of file SqliteSampleBlock.cpp.
References GetSummary(), and DBConnection::GetSummary256.
|
overridevirtual |
Non-throwing, should fill with zeroes on failure.
Implements SampleBlock.
Definition at line 457 of file SqliteSampleBlock.cpp.
References GetSummary(), and DBConnection::GetSummary64k.
double SqliteSampleBlock::GetSumMax | ( | ) | const |
Definition at line 501 of file SqliteSampleBlock.cpp.
References mSumMax.
double SqliteSampleBlock::GetSumMin | ( | ) | const |
Definition at line 496 of file SqliteSampleBlock.cpp.
References mSumMin.
double SqliteSampleBlock::GetSumRms | ( | ) | const |
Definition at line 506 of file SqliteSampleBlock.cpp.
References mSumRms.
|
inlineprivate |
Definition at line 83 of file SqliteSampleBlock.cpp.
References mBlockID.
Referenced by Delete(), DoGetMinMaxRMS(), DoGetSamples(), GetBlob(), GetSpaceUsage(), GetSummary(), and ~SqliteSampleBlock().
|
private |
Definition at line 700 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 885 of file SqliteSampleBlock.cpp.
References mBlockID, XMLWriter::WriteAttr(), and wxT().
void SqliteSampleBlock::SetSamples | ( | constSamplePtr | src, |
size_t | numsamples, | ||
sampleFormat | srcformat | ||
) |
Definition at line 436 of file SqliteSampleBlock.cpp.
References CalcSummary(), Commit(), mSampleBytes, mSamples, ArrayOf< X >::reinit(), and SetSizes().
|
private |
Definition at line 890 of file SqliteSampleBlock.cpp.
References SAMPLE_SIZE.
Referenced by SetSamples().
|
private |
Definition at line 119 of file SqliteSampleBlock.cpp.
Referenced by Commit(), Delete(), DoGetMinMaxRMS(), GetBlob(), GetBlockID(), GetSpaceUsage(), IsSilent(), Load(), and SaveXML().
|
private |
Definition at line 39 of file SqliteSampleBlock.cpp.
Referenced by Commit(), and GetFloatSampleView().
|
private |
Definition at line 40 of file SqliteSampleBlock.cpp.
Referenced by Commit(), and GetFloatSampleView().
|
private |
Definition at line 117 of file SqliteSampleBlock.cpp.
Referenced by CloseLock(), and ~SqliteSampleBlock().
|
private |
Definition at line 115 of file SqliteSampleBlock.cpp.
Referenced by Conn().
|
private |
Definition at line 122 of file SqliteSampleBlock.cpp.
Referenced by Commit(), Load(), SetSamples(), and SqliteSampleBlock().
|
private |
Definition at line 123 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), DoGetMinMaxRMS(), GetFloatSampleView(), GetSampleCount(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 124 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetSamples(), GetSampleFormat(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 121 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), and SetSamples().
|
private |
Definition at line 126 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), and Commit().
|
private |
Definition at line 127 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), and Commit().
|
private |
Definition at line 129 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetMinMaxRMS(), GetSumMax(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 128 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetMinMaxRMS(), GetSumMin(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 130 of file SqliteSampleBlock.cpp.
Referenced by CalcSummary(), Commit(), DoGetMinMaxRMS(), GetSumRms(), Load(), and SqliteSampleBlock().
|
private |
Definition at line 116 of file SqliteSampleBlock.cpp.
Referenced by Commit(), DoGetMinMaxRMS(), GetBlob(), and Load().
|
private |
Definition at line 113 of file SqliteSampleBlock.cpp.