Audacity 3.2.0
Functions
anonymous_namespace{Sequence.cpp} Namespace Reference

Functions

void ensureSampleBufferSize (SampleBuffer &buffer, sampleFormat format, size_t &size, size_t required, SampleBuffer *pSecondBuffer=nullptr)
 
bool Overflows (double numSamples)
 
SampleBlockPtr ShareOrCopySampleBlock (SampleBlockFactory *pFactory, sampleFormat format, SampleBlockPtr sb)
 

Function Documentation

◆ ensureSampleBufferSize()

void anonymous_namespace{Sequence.cpp}::ensureSampleBufferSize ( SampleBuffer buffer,
sampleFormat  format,
size_t &  size,
size_t  required,
SampleBuffer pSecondBuffer = nullptr 
)

Definition at line 112 of file Sequence.cpp.

115 {
116 // This should normally do nothing, but it is a defense against corrupt
117 // projects than might have inconsistent block files bigger than the
118 // expected maximum size.
119 if (size < required) {
120 // reallocate
121 buffer.Allocate(required, format);
122 if (pSecondBuffer && pSecondBuffer->ptr())
123 pSecondBuffer->Allocate(required, format);
124 if (!buffer.ptr() || (pSecondBuffer && !pSecondBuffer->ptr())) {
125 // malloc failed
126 // Perhaps required is a really crazy value,
127 // and perhaps we should throw an AudacityException, but that is
128 // a second-order concern
130 }
131 size = required;
132 }
133 }
int format
Definition: ExportPCM.cpp:53
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
SampleBuffer & Allocate(size_t count, sampleFormat format)
Definition: SampleFormat.h:138
samplePtr ptr() const
Definition: SampleFormat.h:152

References SampleBuffer::Allocate(), format, SampleBuffer::ptr(), size, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by Sequence::ConvertToSampleFormat(), Sequence::Copy(), Sequence::Delete(), and Sequence::SetSamples().

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

◆ Overflows()

bool anonymous_namespace{Sequence.cpp}::Overflows ( double  numSamples)
inline

Definition at line 473 of file Sequence.cpp.

474 {
475 return numSamples > wxLL(9223372036854775807);
476 }

Referenced by Sequence::AppendBlock(), Sequence::AppendSharedBlock(), Sequence::DoAppend(), Sequence::InsertSilence(), and Sequence::Paste().

Here is the caller graph for this function:

◆ ShareOrCopySampleBlock()

SampleBlockPtr anonymous_namespace{Sequence.cpp}::ShareOrCopySampleBlock ( SampleBlockFactory pFactory,
sampleFormat  format,
SampleBlockPtr  sb 
)

Definition at line 478 of file Sequence.cpp.

480 {
481 if ( pFactory ) {
482 // must copy contents to a fresh SampleBlock object in another database
483 auto sampleCount = sb->GetSampleCount();
485 sb->GetSamples( buffer.ptr(), format, 0, sampleCount );
486 sb = pFactory->Create( buffer.ptr(), sampleCount, format );
487 }
488 else
489 // Can just share
490 ;
491 return sb;
492 }
SampleBlockPtr Create(constSamplePtr src, size_t numsamples, sampleFormat srcformat)
Definition: SampleBlock.cpp:26
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References SampleBlockFactory::Create(), and format.

Referenced by Sequence::AppendBlock(), and Sequence::Paste().

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