Skip to content

Commit 4eac801

Browse files
liberato-at-chromiumCommit Bot
authored andcommitted
Install callbacks for the AVDA sync init path.
Previously, we didn't bother to install callbacks for the sync init path for |surface_chooser_|, because there wasn't any need for the chooser to choose anything. However, now that we request compositor feedback for overlay promotion, we still might ask the chooser to choose. When it does, it'll crash without a callback. This CL installs the callbacks so that the chooser is in a good state even in the sync path. Then, it doesn't matter if we ask it questions, since it will (correctly) answer "use SurfaceTexture". It also adds a check to the appropriate unit test. Bug: 772899, 772613 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: Ie0eb6bf5febcdb21119b734d3f2483e4d5aa9d70 Reviewed-on: https://chromium-review.googlesource.com/706250 Commit-Queue: Frank Liberato <[email protected]> Reviewed-by: Thomas Guilbert <[email protected]> Cr-Commit-Position: refs/heads/master@{#507441}
1 parent f87cf88 commit 4eac801

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

media/gpu/android/android_video_decode_accelerator.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ void AndroidVideoDecodeAccelerator::StartSurfaceChooser() {
409409

410410
surface_chooser_state_.is_fullscreen = config_.overlay_info.is_fullscreen;
411411

412+
surface_chooser_->SetClientCallbacks(
413+
base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition,
414+
weak_this_factory_.GetWeakPtr()),
415+
base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition,
416+
weak_this_factory_.GetWeakPtr(), nullptr));
417+
412418
// Handle the sync path, which must use SurfaceTexture anyway. Note that we
413419
// check both |during_initialize_| and |deferred_initialization_pending_|,
414420
// since we might get here during deferred surface creation. In that case,
@@ -426,6 +432,9 @@ void AndroidVideoDecodeAccelerator::StartSurfaceChooser() {
426432
if (during_initialize_ && !deferred_initialization_pending_) {
427433
DCHECK(!config_.overlay_info.HasValidSurfaceId());
428434
DCHECK(!config_.overlay_info.HasValidRoutingToken());
435+
// Note that we might still send feedback to |surface_chooser_|, which might
436+
// call us back. However, it will only ever tell us to use SurfaceTexture,
437+
// since we have no overlay factory anyway.
429438
OnSurfaceTransition(nullptr);
430439
return;
431440
}
@@ -448,11 +457,6 @@ void AndroidVideoDecodeAccelerator::StartSurfaceChooser() {
448457
// the synchronous case. It will be soon, though. For pre-M, we rely on the
449458
// fact that |surface_chooser_| won't tell us to use a SurfaceTexture while
450459
// waiting for an overlay to become ready, for example.
451-
surface_chooser_->SetClientCallbacks(
452-
base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition,
453-
weak_this_factory_.GetWeakPtr()),
454-
base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition,
455-
weak_this_factory_.GetWeakPtr(), nullptr));
456460
surface_chooser_->UpdateState(std::move(factory), surface_chooser_state_);
457461
}
458462

media/gpu/android/android_video_decode_accelerator_unittest.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ TEST_F(AndroidVideoDecodeAcceleratorTest,
237237
config_.is_deferred_initialization_allowed = false;
238238

239239
EXPECT_CALL(*codec_allocator_, MockCreateMediaCodecSync(_, _));
240+
// AVDA must set client callbacks even in sync mode, so that the chooser is
241+
// in a sane state. crbug.com/772899 .
242+
EXPECT_CALL(*chooser_, MockSetClientCallbacks());
240243
ASSERT_TRUE(InitializeAVDA());
244+
testing::Mock::VerifyAndClearExpectations(chooser_);
241245
}
242246

243247
TEST_F(AndroidVideoDecodeAcceleratorTest, FailingToCreateACodecSyncIsAnError) {

0 commit comments

Comments
 (0)