Skip to content

Commit

Permalink
[M-110] media/gpu/v4l2VEA: Set state to kInitialized in early Initial…
Browse files Browse the repository at this point in the history
…izeTask()

V4L2VEA calls NotifyError() in SetErrorState() if the current state
is neither kError nor kUninitialized. The latter is because
NotifyError() must not be called in Initialize(). InitializeTask()
is executed after Initialize() returns. It must call NotifyError()
if the initialization done in InitializeTask() fails.
However, the state was set to kInitialized from kUninitialized in
the later InitializeTask(), so SetErrorState() in early
InitializeTask() doesn't call NotifyError(). This causes the stuck
of encoding. This CL fixes the bug by setting the state to
kInitialized in the beginning of InitializeTask().

(cherry picked from commit 2eabc1d)

Bug: b:266643681
Bug: b:267501137
Test: Google Meet 49p call on trogdor
Test: video_encode_accelerator_tests on trogdor
Change-Id: I0fc9395e59c0fbebc2d5d7e1cd5fc72f61933cbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4190431
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Steve Cho <stevecho@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1097186}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4216732
Reviewed-by: Fritz Koenig <frkoenig@chromium.org>
Cr-Commit-Position: refs/branch-heads/5481@{#895}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
Hirokazu Honda authored and Chromium LUCI CQ committed Feb 2, 2023
1 parent d468674 commit 182d9f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion media/gpu/v4l2/v4l2_video_encode_accelerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ void V4L2VideoEncodeAccelerator::InitializeTask(const Config& config) {
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
TRACE_EVENT0("media,gpu", "V4L2VEA::InitializeTask");

// Set kInitialized here so that NotifyError() is invoked from here.
encoder_state_ = kInitialized;

native_input_mode_ =
config.storage_type.value_or(Config::StorageType::kShmem) ==
Config::StorageType::kGpuMemoryBuffer;
Expand Down Expand Up @@ -348,7 +351,6 @@ void V4L2VideoEncodeAccelerator::InitializeTask(const Config& config) {
return;
}

encoder_state_ = kInitialized;
uint32_t bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_CBR;
switch (config.bitrate.mode()) {
case Bitrate::Mode::kConstant:
Expand Down
3 changes: 2 additions & 1 deletion media/gpu/v4l2/v4l2_video_encode_accelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
// Internal state of the encoder.
enum State {
kUninitialized, // Initialize() not yet called.
kInitialized, // Initialize() returned true; ready to start encoding.
kInitialized, // Initialize() returned true. The encoding is ready after
// InitializeTask() completes successfully.
kEncoding, // Encoding frames.
kFlushing, // Flushing frames.
kError, // Error in encoder state.
Expand Down

0 comments on commit 182d9f7

Please sign in to comment.