![]() |
Audacity 3.2.0
|
Adapts SampleTrack to the interface AudioGraph::Source. More...
#include <SampleTrackSource.h>
Public Types | |
using | Poller = std::function< bool(sampleCount blockSize)> |
Type of function returning false if user cancels progress. More... | |
![]() | |
using | Buffers = AudioGraph::Buffers |
Public Member Functions | |
SampleTrackSource (const SampleTrack &left, const SampleTrack *pRight, sampleCount start, sampleCount len, Poller pollUser) | |
~SampleTrackSource () 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... | |
![]() | |
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 SampleTrack & | mLeft |
const SampleTrack *const | mpRight |
const Poller | mPollUser |
sampleCount | mPos {} |
sampleCount | mOutputRemaining {} |
size_t | mLastProduced {} |
size_t | mFetched {} |
bool | mInitialized { false } |
Adapts SampleTrack to the interface AudioGraph::Source.
Definition at line 25 of file SampleTrackSource.h.
using SampleTrackSource::Poller = std::function<bool(sampleCount blockSize)> |
Type of function returning false if user cancels progress.
Definition at line 28 of file SampleTrackSource.h.
SampleTrackSource::SampleTrackSource | ( | const SampleTrack & | left, |
const SampleTrack * | pRight, | ||
sampleCount | start, | ||
sampleCount | len, | ||
Poller | pollUser | ||
) |
|
overridedefault |
|
overridevirtual |
Always true.
Implements AudioGraph::Source.
Definition at line 42 of file SampleTrackSource.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 37 of file SampleTrackSource.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 SampleTrackSource.cpp.
References AcceptsBlockSize(), AcceptsBuffers(), AudioGraph::Buffers::BlockSize(), AudioGraph::Buffers::Channels(), SampleTrack::GetFloats(), AudioGraph::Buffers::GetWritePosition(), limitSampleBufferSize(), mFetched, min(), mInitialized, mLastProduced, mLeft, mPos, mpRight, AudioGraph::Buffers::Remaining(), and Remaining().
|
overridevirtual |
Can test for user cancellation.
Implements AudioGraph::Source.
Definition at line 86 of file SampleTrackSource.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 47 of file SampleTrackSource.cpp.
References mOutputRemaining.
Referenced by Acquire().
|
private |
Definition at line 56 of file SampleTrackSource.h.
|
private |
Definition at line 57 of file SampleTrackSource.h.
Referenced by Acquire().
|
private |
Definition at line 55 of file SampleTrackSource.h.
|
private |
Definition at line 49 of file SampleTrackSource.h.
Referenced by Acquire().
|
private |
Definition at line 54 of file SampleTrackSource.h.
Referenced by AcceptsBuffers(), Release(), and Remaining().
|
private |
Definition at line 51 of file SampleTrackSource.h.
Referenced by Release().
|
private |
Definition at line 53 of file SampleTrackSource.h.
|
private |
Definition at line 50 of file SampleTrackSource.h.
Referenced by Acquire().