diff options
author | Pin-chih Lin <johnylin@google.com> | 2018-05-30 14:03:52 +0800 |
---|---|---|
committer | Pin-chih Lin <johnylin@google.com> | 2018-06-19 11:08:52 +0800 |
commit | 29d50d91cc8829fa92a72276750681dcd30f38c4 (patch) | |
tree | a42577f0ec3bb9be0bc35416ef247166d481ae41 | |
parent | 62585f03f765b54869bf8687f9a5f384fd3c000e (diff) | |
download | v4l2_codec2-29d50d91cc8829fa92a72276750681dcd30f38c4.tar.gz |
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
-rw-r--r-- | C2VDAComponent.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp index ba17deb..fcae9df 100644 --- a/C2VDAComponent.cpp +++ b/C2VDAComponent.cpp @@ -273,8 +273,6 @@ void C2VDAComponent::onQueueWork(std::unique_ptr<C2Work> work) { 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 @@ void C2VDAComponent::onDequeueWork() { 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 @@ void C2VDAComponent::onFlushDone() { // 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() { |