Commit 8e829fc5 authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

media: V4L2StatefulVDBackend skip flush when no pending request

Originally, V4L2StatefulVDBackend skipped flush when the V4L2 output
queue is not streaming. However, it doesn't mean there is no pending
requests needed to be flushed. This CL fixes this issue by introduing
a new flag to track if there is any pending request.

BUG=b:170728773
TEST=android.media.cts.AdaptivePlaybackTest#testH264_adaptiveReconfigDrc
TEST=tast.video.DecodeAccel.{h264,vp8,vp9}

Change-Id: I45d2b6072e47f23a3a61ccb622bef206ad1bb6e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532027
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827678}
parent 2b4c65f0
......@@ -106,6 +106,10 @@ void V4L2StatefulVideoDecoderBackend::EnqueueDecodeTask(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOGF(3);
if (!buffer->end_of_stream()) {
has_pending_requests_ = true;
}
decode_request_queue_.push(
DecodeRequest(std::move(buffer), std::move(decode_cb), bitstream_id));
......@@ -443,10 +447,9 @@ bool V4L2StatefulVideoDecoderBackend::InitiateFlush(
client_->InitiateFlush();
flush_cb_ = std::move(flush_cb);
// Special case: if our CAPTURE queue is not streaming, we cannot receive
// the CAPTURE buffer with the LAST flag set that signals the end of flush.
// In this case, we should complete the flush immediately.
if (!output_queue_->IsStreaming())
// Special case: if we haven't received any decoding request, we could
// complete the flush immediately.
if (!has_pending_requests_)
return CompleteFlush();
// Send the STOP command to the V4L2 device. The device will let us know
......@@ -491,6 +494,7 @@ bool V4L2StatefulVideoDecoderBackend::CompleteFlush() {
// Resume decoding if data is available.
ScheduleDecodeWork();
has_pending_requests_ = false;
return true;
}
......@@ -611,6 +615,8 @@ void V4L2StatefulVideoDecoderBackend::ClearPendingRequests(
std::move(decode_request_queue_.front().decode_cb).Run(status);
decode_request_queue_.pop();
}
has_pending_requests_ = false;
}
// TODO(b:149663704) move into helper function shared between both backends?
......
......@@ -144,6 +144,12 @@ class V4L2StatefulVideoDecoderBackend : public V4L2VideoDecoderBackend {
// event completes.
base::OnceClosure resolution_change_cb_;
// Whether there is any decoding request coming after
// initialization/flush/reset is finished.
// This flag is set on the first decode request, and reset after a successful
// flush or reset.
bool has_pending_requests_ = false;
base::WeakPtr<V4L2StatefulVideoDecoderBackend> weak_this_;
base::WeakPtrFactory<V4L2StatefulVideoDecoderBackend> weak_this_factory_{
this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment