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 115 of file Sequence.cpp.

118 {
119 // This should normally do nothing, but it is a defense against corrupt
120 // projects than might have inconsistent block files bigger than the
121 // expected maximum size.
122 if (size < required) {
123 // reallocate
124 buffer.Allocate(required, format);
125 if (pSecondBuffer && pSecondBuffer->ptr())
126 pSecondBuffer->Allocate(required, format);
127 if (!buffer.ptr() || (pSecondBuffer && !pSecondBuffer->ptr())) {
128 // malloc failed
129 // Perhaps required is a really crazy value,
130 // and perhaps we should throw an AudacityException, but that is
131 // a second-order concern
133 }
134 size = required;
135 }
136 }
#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:151
samplePtr ptr() const
Definition: SampleFormat.h:165

References SampleBuffer::Allocate(), anonymous_namespace{ExportPCM.cpp}::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 476 of file Sequence.cpp.

477 {
478 return numSamples > wxLL(9223372036854775807);
479 }

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 481 of file Sequence.cpp.

483 {
484 if ( pFactory ) {
485 // must copy contents to a fresh SampleBlock object in another database
486 auto sampleCount = sb->GetSampleCount();
488 sb->GetSamples( buffer.ptr(), format, 0, sampleCount );
489 sb = pFactory->Create( buffer.ptr(), sampleCount, format );
490 }
491 else
492 // Can just share
493 ;
494 return sb;
495 }
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 anonymous_namespace{ExportPCM.cpp}::format.

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

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