codec2: fix checking flush state in onQueueWork
In CCodec aspect, flush is complete after flush signal is finished and would
not be blocked. So actually CCodec will not know the internal state of the
component, and it is valid for CCodec to start queuing works then.
The component should internally block the work queue until flush is complete
(just like we did for draining).
Bug: 80452412
Test: CTsMediaTestCases android.media.cts.DecoderTest#testCodecResetsH264WithSurface
Change-Id: I01b2af1ff4a94eff2ad3cdaebbe9c44709a04d8c
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index ba17deb..fcae9df 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -273,8 +273,6 @@
ALOGV("onQueueWork: flags=0x%x, index=%llu, timestamp=%llu", work->input.flags,
work->input.ordinal.frameIndex.peekull(), work->input.ordinal.timestamp.peekull());
EXPECT_RUNNING_OR_RETURN_ON_ERROR();
- // It is illegal for client to put new works while component is still flushing.
- CHECK_NE(mComponentState, ComponentState::FLUSHING);
uint32_t drainMode = NO_DRAIN;
if (work->input.flags & C2FrameData::FLAG_END_OF_STREAM) {
@@ -294,8 +292,9 @@
if (mQueue.empty()) {
return;
}
- if (mComponentState == ComponentState::DRAINING) {
- ALOGV("Temporarily stop dequeueing works since component is draining.");
+ if (mComponentState == ComponentState::DRAINING ||
+ mComponentState == ComponentState::FLUSHING) {
+ ALOGV("Temporarily stop dequeueing works since component is draining/flushing.");
return;
}
if (mComponentState != ComponentState::STARTED) {
@@ -541,6 +540,10 @@
// Reset the timestamp record.
mLastOutputTimestamp = -1;
mComponentState = ComponentState::STARTED;
+
+ // Work dequeueing was stopped while component flushing. Restart it.
+ mTaskRunner->PostTask(FROM_HERE,
+ ::base::Bind(&C2VDAComponent::onDequeueWork, ::base::Unretained(this)));
}
void C2VDAComponent::onStopDone() {