CCodec: skip first N longest work inside total delay
If the client pauses pushing input to the component, work items inside
total delay may sit in the pipeline indefinitely. We don't want to
error out for those work. Once the client pushes EOS, ensure all work
items finishes within reasonable time regardless of delay.
Bug: 124355114
Test: manual
Test: atest CtsSecurityTestCases:StagefrightTest
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Change-Id: I0e95b2ddb94482da855d70cbe75f6bffaaffe279
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 6842fa5..a278a81 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -1557,6 +1557,7 @@
mCCodecCallback(callback),
mNumInputSlots(kSmoothnessFactor),
mNumOutputSlots(kSmoothnessFactor),
+ mDelay(0),
mFrameIndex(0u),
mFirstValidFrameIndex(0u),
mMetaMode(MODE_NONE),
@@ -2104,11 +2105,13 @@
}
}
- mNumInputSlots =
- (inputDelay ? inputDelay.value : 0) +
- (pipelineDelay ? pipelineDelay.value : 0) +
- kSmoothnessFactor;
- mNumOutputSlots = (outputDelay ? outputDelay.value : 0) + kSmoothnessFactor;
+ uint32_t inputDelayValue = inputDelay ? inputDelay.value : 0;
+ uint32_t pipelineDelayValue = pipelineDelay ? pipelineDelay.value : 0;
+ uint32_t outputDelayValue = outputDelay ? outputDelay.value : 0;
+
+ mNumInputSlots = inputDelayValue + pipelineDelayValue + kSmoothnessFactor;
+ mNumOutputSlots = outputDelayValue + kSmoothnessFactor;
+ mDelay = inputDelayValue + pipelineDelayValue + outputDelayValue;
// TODO: get this from input format
bool secure = mComponent->getName().find(".secure") != std::string::npos;
@@ -2397,9 +2400,9 @@
{
Mutexed<PipelineWatcher>::Locked watcher(mPipelineWatcher);
- watcher->inputDelay(inputDelay ? inputDelay.value : 0)
- .pipelineDelay(pipelineDelay ? pipelineDelay.value : 0)
- .outputDelay(outputDelay ? outputDelay.value : 0)
+ watcher->inputDelay(inputDelayValue)
+ .pipelineDelay(pipelineDelayValue)
+ .outputDelay(outputDelayValue)
.smoothnessFactor(kSmoothnessFactor);
watcher->flush();
}
@@ -2816,7 +2819,11 @@
}
PipelineWatcher::Clock::duration CCodecBufferChannel::elapsed() {
- return mPipelineWatcher.lock()->elapsed(PipelineWatcher::Clock::now());
+ // When client pushed EOS, we want all the work to be done quickly.
+ // Otherwise, component may have stalled work due to input starvation up to
+ // the sum of the delay in the pipeline.
+ size_t n = mInputMetEos ? 0 : mDelay;
+ return mPipelineWatcher.lock()->elapsed(PipelineWatcher::Clock::now(), n);
}
void CCodecBufferChannel::setMetaMode(MetaMode mode) {