codec2: allow output buffer returned after component stopped
Output buffer might be returnedfrom client after component is stopped
Bug: 72354012
Test: run stagefright cmdtool to decode video
Change-Id: Iea03d081778b9779d15afb7b5ff9d95bdb238129
(cherry picked from commit 6bdaded5a172b285de0f23fab97e4ea8f7bc3747)
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 5a303e5..b13cc16 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -659,8 +659,14 @@
void C2VDAComponent::onOutputBufferReturned(int32_t pictureBufferId) {
DCHECK(mTaskRunner->BelongsToCurrentThread());
ALOGV("onOutputBufferReturned: picture id=%d", pictureBufferId);
- EXPECT_RUNNING_OR_RETURN_ON_ERROR();
+ if (mComponentState == ComponentState::UNINITIALIZED) {
+ // Output buffer is returned from client after component is stopped. Just let the buffer be
+ // released.
+ return;
+ }
+ // TODO(johnylin): when buffer is returned, we should confirm that output format is not changed
+ // yet. If changed, just let the buffer be released.
GraphicBlockInfo* info = getGraphicBlockById(pictureBufferId);
if (!info) {
reportError(C2_CORRUPTED);