V4L2Decoder: Clear mFrameAtDevice when streamoff the output queue
|mFrameAtDevice| is to track the buffers enqueued in the V4L2 output
queue. When we streamoff the V4L2 queue, all of the enqueued buffers
are dropped immediately. Therefore we should also clear
|mFrameAtDevice| at the same time.
Bug: 166072201
Test: Run gts.DashTest#testWidevineVp9AdaptiveWithRendererDisabling
and check the error message added by this CL doesn't appear.
Change-Id: Ibda5949710e66e78a6f49c80c57e94c93fe69afc
diff --git a/components/V4L2Decoder.cpp b/components/V4L2Decoder.cpp
index f066fd4..a5ef3fb 100644
--- a/components/V4L2Decoder.cpp
+++ b/components/V4L2Decoder.cpp
@@ -317,6 +317,7 @@
// Streamoff V4L2 queues to drop input and output buffers.
mDevice->StopPolling();
mOutputQueue->Streamoff();
+ mFrameAtDevice.clear();
mInputQueue->Streamoff();
// Streamon input queue again.
@@ -471,6 +472,7 @@
mOutputQueue->Streamoff();
mOutputQueue->DeallocateBuffers();
+ mFrameAtDevice.clear();
mBlockIdToV4L2Id.clear();
if (mOutputQueue->AllocateBuffers(*numOutputBuffers, V4L2_MEMORY_DMABUF) == 0) {
@@ -557,6 +559,11 @@
ALOGV("QBUF to output queue, blockId=%u, V4L2Id=%u", blockId, v4l2Id);
std::move(*outputBuffer).QueueDMABuf(frame->getFDs());
+ if (mFrameAtDevice.find(v4l2Id) != mFrameAtDevice.end()) {
+ ALOGE("%s(): V4L2 buffer %d already enqueued.", __func__, v4l2Id);
+ onError();
+ return;
+ }
mFrameAtDevice.insert(std::make_pair(v4l2Id, std::move(frame)));
tryFetchVideoFrame();