MCPcopy Create free account
hub / github.com/audacity/audacity / FetchProcessAndAdvance

Method FetchProcessAndAdvance

libraries/lib-mixer/EffectStage.cpp:225–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225std::optional<size_t> EffectStage::FetchProcessAndAdvance(
226 Buffers &data, size_t bound, bool doZeroes, size_t outBufferOffset)
227{
228 std::optional<size_t> oCurBlockSize;
229 // Generator always supplies zeroes in
230 doZeroes = doZeroes || !mIsProcessor;
231 if (!doZeroes)
232 oCurBlockSize = mUpstream.Acquire(mInBuffers, bound);
233 else {
234 if (!mCleared) {
235 // Need to do this the first time, only, that we begin to give zeroes
236 // to the processor
237 mInBuffers.Rewind();
238 const auto blockSize = mInBuffers.BlockSize();
239 for (size_t ii = 0; ii < mInBuffers.Channels(); ++ii) {
240 auto p = &mInBuffers.GetWritePosition(ii);
241 std::fill(p, p + blockSize, 0);
242 }
243 mCleared = true;
244 }
245 oCurBlockSize = {
246 mIsProcessor ? bound : limitSampleBufferSize(bound, mDelayRemaining) };
247 if (!mIsProcessor)
248 // Do this (ignoring result) so we can correctly Release() upstream
249 mUpstream.Acquire(mInBuffers, bound);
250 }
251 if (!oCurBlockSize)
252 return {};
253
254 const auto curBlockSize = *oCurBlockSize;
255 if (curBlockSize == 0)
256 assert(doZeroes || mUpstream.Remaining() == 0); // post of Acquire()
257 else {
258 // Called only in Acquire()
259 // invariant or post of mUpstream.Acquire() satisfies pre of Process()
260 // because curBlockSize <= bound <= mInBuffers.blockSize()
261 // == data.BlockSize()
262 // and mInBuffers.BlockSize() <= mInBuffers.Remaining() by invariant
263 // and data.BlockSize() <= data.Remaining() by pre of Acquire()
264 for (size_t ii = 0, nn = mInstances.size(); ii < nn; ++ii) {
265 auto &pInstance = mInstances[ii];
266 if (!pInstance)
267 continue;
268 if (!Process(*pInstance, ii, data, curBlockSize, outBufferOffset))
269 return {};
270 }
271
272 if (doZeroes) {
273 // Either a generator or doing the tail; will count down delay
274 mLastZeroes = limitSampleBufferSize(curBlockSize, DelayRemaining());
275 if (!mIsProcessor) {
276 // This allows polling the progress meter for a generator
277 if (!mUpstream.Release())
278 return {};
279 }
280 }
281 else {
282 // Will count down the upstream

Callers

nothing calls this directly

Calls 10

limitSampleBufferSizeFunction · 0.85
ProcessFunction · 0.85
RewindMethod · 0.80
ChannelsMethod · 0.80
AcquireMethod · 0.45
RemainingMethod · 0.45
sizeMethod · 0.45
ReleaseMethod · 0.45
AdvanceMethod · 0.45
RotateMethod · 0.45

Tested by

no test coverage detected