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

109 {
110 // This should normally do nothing, but it is a defense against corrupt
111 // projects than might have inconsistent block files bigger than the
112 // expected maximum size.
113 if (size < required) {
114 // reallocate
115 buffer.Allocate(required, format);
116 if (pSecondBuffer && pSecondBuffer->ptr())
117 pSecondBuffer->Allocate(required, format);
118 if (!buffer.ptr() || (pSecondBuffer && !pSecondBuffer->ptr())) {
119 // malloc failed
120 // Perhaps required is a really crazy value,
121 // and perhaps we should throw an AudacityException, but that is
122 // a second-order concern
124 }
125 size = required;
126 }
127 }
#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 467 of file Sequence.cpp.

468 {
469 return numSamples > wxLL(9223372036854775807);
470 }

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

474 {
475 if ( pFactory ) {
476 // must copy contents to a fresh SampleBlock object in another database
477 auto sampleCount = sb->GetSampleCount();
479 sb->GetSamples( buffer.ptr(), format, 0, sampleCount );
480 sb = pFactory->Create( buffer.ptr(), sampleCount, format );
481 }
482 else
483 // Can just share
484 ;
485 return sb;
486 }
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: