Audacity 3.2.0
|
Adapts WideSampleSequence to the interface AudioGraph::Source. More...
#include <WideSampleSource.h>
Public Types | |
using | Poller = std::function< bool(sampleCount blockSize)> |
Type of function returning false if user cancels progress. More... | |
Public Types inherited from AudioGraph::Source | |
using | Buffers = AudioGraph::Buffers |
Public Member Functions | |
WideSampleSource (const WideSampleSequence &sequence, size_t nChannels, sampleCount start, sampleCount len, Poller pollUser) | |
~WideSampleSource () override | |
bool | AcceptsBuffers (const Buffers &buffers) const override |
bool | AcceptsBlockSize (size_t blockSize) const override |
Always true. More... | |
std::optional< size_t > | Acquire (Buffers &data, size_t bound) override |
Occupy vacant space in Buffers with some data. More... | |
sampleCount | Remaining () const override |
Result includes any amount Acquired and not yet Released. More... | |
bool | Release () override |
Can test for user cancellation. More... | |
Public Member Functions inherited from AudioGraph::Source | |
virtual | ~Source () |
virtual bool | AcceptsBuffers (const Buffers &buffers) const =0 |
virtual bool | AcceptsBlockSize (size_t blockSize) const =0 |
virtual std::optional< size_t > | Acquire (Buffers &data, size_t bound)=0 |
Occupy vacant space in Buffers with some data. More... | |
virtual sampleCount | Remaining () const =0 |
Result includes any amount Acquired and not yet Released. More... | |
virtual bool | Release ()=0 |
Caller is done examining last Acquire()d positions. More... | |
virtual bool | Terminates () const |
Needed only to make some postconditions assertable; defaults true. More... | |
Private Attributes | |
const WideSampleSequence & | mSequence |
const size_t | mnChannels |
const Poller | mPollUser |
sampleCount | mPos {} |
sampleCount | mOutputRemaining {} |
size_t | mLastProduced {} |
size_t | mFetched {} |
bool | mInitialized { false } |
Adapts WideSampleSequence to the interface AudioGraph::Source.
Definition at line 24 of file WideSampleSource.h.
using WideSampleSource::Poller = std::function<bool(sampleCount blockSize)> |
Type of function returning false if user cancels progress.
Definition at line 27 of file WideSampleSource.h.
WideSampleSource::WideSampleSource | ( | const WideSampleSequence & | sequence, |
size_t | nChannels, | ||
sampleCount | start, | ||
sampleCount | len, | ||
Poller | pollUser | ||
) |
nChannels <= sequence.NChannels()
Remaining()
== len Definition at line 25 of file WideSampleSource.cpp.
References WideSampleSequence::NChannels().
|
overridedefault |
|
overridevirtual |
Always true.
Implements AudioGraph::Source.
Definition at line 40 of file WideSampleSource.cpp.
Referenced by Acquire().
|
overridevirtual |
If constructed with positive length, then accepts buffers only when number of channels is positive
Implements AudioGraph::Source.
Definition at line 35 of file WideSampleSource.cpp.
References AudioGraph::Buffers::Channels(), and mOutputRemaining.
Referenced by Acquire().
|
overridevirtual |
Occupy vacant space in Buffers with some data.
May exceeed a single block of production Can assume same buffer is passed each time, while the caller advances it over the previous production, or discards it, or rotates the buffer. May rewind or rotate the buffer.
data
or nullopt to fail AcceptsBuffers(data)
AcceptsBlockSize(data.BlockSize())
bound <= data.BlockSize()
data.BlockSize() <= data.Remaining()
!result || *result <= bound
!result || *result <= data.Remaining()
!result || *result <= Remaining()
data.Remaining() > 0
!result || bound == 0 || Remaining() == 0 || *result > 0
(progress guarantee) !Terminates()
or Remaining()
was not previously defined, or is unchanged Implements AudioGraph::Source.
Definition at line 52 of file WideSampleSource.cpp.
References AcceptsBlockSize(), AcceptsBuffers(), AudioGraph::Buffers::BlockSize(), WideSampleSequence::GetFloats(), AudioGraph::Buffers::GetWritePosition(), limitSampleBufferSize(), mFetched, min(), mInitialized, mLastProduced, mnChannels, mPos, mSequence, AudioGraph::Buffers::Remaining(), Remaining(), and stackAllocate.
|
overridevirtual |
Can test for user cancellation.
Implements AudioGraph::Source.
Definition at line 89 of file WideSampleSource.cpp.
References mFetched, mLastProduced, mOutputRemaining, mPollUser, and mPos.
|
overridevirtual |
Result includes any amount Acquired and not yet Released.
May be undefined before the first successful call to Acquire()
result >= 0
Implements AudioGraph::Source.
Definition at line 45 of file WideSampleSource.cpp.
References mOutputRemaining.
Referenced by Acquire().
|
private |
Definition at line 56 of file WideSampleSource.h.
|
private |
Definition at line 57 of file WideSampleSource.h.
Referenced by Acquire().
|
private |
Definition at line 55 of file WideSampleSource.h.
|
private |
Definition at line 50 of file WideSampleSource.h.
Referenced by Acquire().
|
private |
Definition at line 54 of file WideSampleSource.h.
Referenced by AcceptsBuffers(), Release(), and Remaining().
|
private |
Definition at line 51 of file WideSampleSource.h.
Referenced by Release().
|
private |
Definition at line 53 of file WideSampleSource.h.
|
private |
Definition at line 49 of file WideSampleSource.h.
Referenced by Acquire().