Commit 57673f4d authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Rename AVDACodecAllocator to CodecAllocator.

Since AVDA is on it's way out... this also replaces all instances of
base::Bind with the appropriate version (generally base::BindOnce).

BUG=none
TEST=bots
R=liberato

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I75f8dd4895f7404fe752cf02d495a198b8a78a6a
Reviewed-on: https://chromium-review.googlesource.com/1252961
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595323}
parent f0ac64f0
...@@ -157,8 +157,6 @@ component("gpu") { ...@@ -157,8 +157,6 @@ component("gpu") {
"android/android_video_surface_chooser.h", "android/android_video_surface_chooser.h",
"android/android_video_surface_chooser_impl.cc", "android/android_video_surface_chooser_impl.cc",
"android/android_video_surface_chooser_impl.h", "android/android_video_surface_chooser_impl.h",
"android/avda_codec_allocator.cc",
"android/avda_codec_allocator.h",
"android/avda_codec_image.cc", "android/avda_codec_image.cc",
"android/avda_codec_image.h", "android/avda_codec_image.h",
"android/avda_picture_buffer_manager.cc", "android/avda_picture_buffer_manager.cc",
...@@ -168,6 +166,8 @@ component("gpu") { ...@@ -168,6 +166,8 @@ component("gpu") {
"android/avda_state_provider.h", "android/avda_state_provider.h",
"android/avda_surface_bundle.cc", "android/avda_surface_bundle.cc",
"android/avda_surface_bundle.h", "android/avda_surface_bundle.h",
"android/codec_allocator.cc",
"android/codec_allocator.h",
"android/codec_image.cc", "android/codec_image.cc",
"android/codec_image.h", "android/codec_image.h",
"android/codec_image_group.cc", "android/codec_image_group.cc",
...@@ -438,7 +438,7 @@ source_set("android_video_decode_accelerator_unittests") { ...@@ -438,7 +438,7 @@ source_set("android_video_decode_accelerator_unittests") {
sources = [ sources = [
"android/android_video_decode_accelerator_unittest.cc", "android/android_video_decode_accelerator_unittest.cc",
"android/android_video_surface_chooser_impl_unittest.cc", "android/android_video_surface_chooser_impl_unittest.cc",
"android/avda_codec_allocator_unittest.cc", "android/codec_allocator_unittest.cc",
"android/codec_image_group_unittest.cc", "android/codec_image_group_unittest.cc",
"android/codec_image_unittest.cc", "android/codec_image_unittest.cc",
"android/codec_wrapper_unittest.cc", "android/codec_wrapper_unittest.cc",
......
...@@ -118,7 +118,7 @@ constexpr base::TimeDelta IdleTimerTimeOut = base::TimeDelta::FromSeconds(1); ...@@ -118,7 +118,7 @@ constexpr base::TimeDelta IdleTimerTimeOut = base::TimeDelta::FromSeconds(1);
// On low end devices (< KitKat is always low-end due to buggy MediaCodec), // On low end devices (< KitKat is always low-end due to buggy MediaCodec),
// defer the surface creation until the codec is actually used if we know no // defer the surface creation until the codec is actually used if we know no
// software fallback exists. // software fallback exists.
bool ShouldDeferSurfaceCreation(AVDACodecAllocator* codec_allocator, bool ShouldDeferSurfaceCreation(CodecAllocator* codec_allocator,
const OverlayInfo& overlay_info, const OverlayInfo& overlay_info,
VideoCodec codec, VideoCodec codec,
DeviceInfo* device_info) { DeviceInfo* device_info) {
...@@ -259,7 +259,7 @@ AndroidVideoDecodeAccelerator::BitstreamRecord::BitstreamRecord( ...@@ -259,7 +259,7 @@ AndroidVideoDecodeAccelerator::BitstreamRecord::BitstreamRecord(
AndroidVideoDecodeAccelerator::BitstreamRecord::~BitstreamRecord() {} AndroidVideoDecodeAccelerator::BitstreamRecord::~BitstreamRecord() {}
AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator( AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
AVDACodecAllocator* codec_allocator, CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser, std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
const MakeGLContextCurrentCallback& make_context_current_cb, const MakeGLContextCurrentCallback& make_context_current_cb,
const GetContextGroupCallback& get_context_group_cb, const GetContextGroupCallback& get_context_group_cb,
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#include "media/base/android/media_crypto_context.h" #include "media/base/android/media_crypto_context.h"
#include "media/base/android_overlay_mojo_factory.h" #include "media/base/android_overlay_mojo_factory.h"
#include "media/base/content_decryption_module.h" #include "media/base/content_decryption_module.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/avda_picture_buffer_manager.h" #include "media/gpu/android/avda_picture_buffer_manager.h"
#include "media/gpu/android/avda_state_provider.h" #include "media/gpu/android/avda_state_provider.h"
#include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/device_info.h" #include "media/gpu/android/device_info.h"
#include "media/gpu/android/surface_chooser_helper.h" #include "media/gpu/android/surface_chooser_helper.h"
#include "media/gpu/gpu_video_decode_accelerator_helpers.h" #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
...@@ -44,13 +44,13 @@ class PromotionHintAggregator; ...@@ -44,13 +44,13 @@ class PromotionHintAggregator;
class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
: public VideoDecodeAccelerator, : public VideoDecodeAccelerator,
public AVDAStateProvider, public AVDAStateProvider,
public AVDACodecAllocatorClient { public CodecAllocatorClient {
public: public:
static VideoDecodeAccelerator::Capabilities GetCapabilities( static VideoDecodeAccelerator::Capabilities GetCapabilities(
const gpu::GpuPreferences& gpu_preferences); const gpu::GpuPreferences& gpu_preferences);
AndroidVideoDecodeAccelerator( AndroidVideoDecodeAccelerator(
AVDACodecAllocator* codec_allocator, CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser, std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
const MakeGLContextCurrentCallback& make_context_current_cb, const MakeGLContextCurrentCallback& make_context_current_cb,
const GetContextGroupCallback& get_context_group_cb, const GetContextGroupCallback& get_context_group_cb,
...@@ -83,7 +83,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator ...@@ -83,7 +83,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
void NotifyError(Error error) override; void NotifyError(Error error) override;
PromotionHintAggregator::NotifyPromotionHintCB GetPromotionHintCB() override; PromotionHintAggregator::NotifyPromotionHintCB GetPromotionHintCB() override;
// AVDACodecAllocatorClient implementation: // CodecAllocatorClient implementation:
void OnCodecConfigured( void OnCodecConfigured(
std::unique_ptr<MediaCodecBridge> media_codec, std::unique_ptr<MediaCodecBridge> media_codec,
scoped_refptr<AVDASurfaceBundle> surface_bundle) override; scoped_refptr<AVDASurfaceBundle> surface_bundle) override;
...@@ -266,7 +266,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator ...@@ -266,7 +266,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
// To expose client callbacks from VideoDecodeAccelerator. // To expose client callbacks from VideoDecodeAccelerator.
Client* client_; Client* client_;
AVDACodecAllocator* codec_allocator_; CodecAllocator* codec_allocator_;
// Callback to set the correct gl context. // Callback to set the correct gl context.
MakeGLContextCurrentCallback make_context_current_cb_; MakeGLContextCurrentCallback make_context_current_cb_;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "media/base/android/mock_media_codec_bridge.h" #include "media/base/android/mock_media_codec_bridge.h"
#include "media/gpu/android/android_video_decode_accelerator.h" #include "media/gpu/android/android_video_decode_accelerator.h"
#include "media/gpu/android/android_video_surface_chooser.h" #include "media/gpu/android/android_video_surface_chooser.h"
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/fake_codec_allocator.h" #include "media/gpu/android/fake_codec_allocator.h"
#include "media/gpu/android/mock_android_video_surface_chooser.h" #include "media/gpu/android/mock_android_video_surface_chooser.h"
#include "media/gpu/android/mock_device_info.h" #include "media/gpu/android/mock_device_info.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include <stddef.h> #include <stddef.h>
...@@ -37,7 +37,7 @@ constexpr base::TimeDelta kHungTaskDetectionTimeout = ...@@ -37,7 +37,7 @@ constexpr base::TimeDelta kHungTaskDetectionTimeout =
// This must be safe to call on any thread. Returns nullptr on failure. // This must be safe to call on any thread. Returns nullptr on failure.
std::unique_ptr<MediaCodecBridge> CreateMediaCodecInternal( std::unique_ptr<MediaCodecBridge> CreateMediaCodecInternal(
AVDACodecAllocator::CodecFactoryCB factory_cb, CodecAllocator::CodecFactoryCB factory_cb,
scoped_refptr<CodecConfig> codec_config, scoped_refptr<CodecConfig> codec_config,
bool requires_software_codec) { bool requires_software_codec) {
TRACE_EVENT0("media", "CodecAllocator::CreateMediaCodec"); TRACE_EVENT0("media", "CodecAllocator::CreateMediaCodec");
...@@ -83,23 +83,22 @@ void DeleteMediaCodecAndSignal(std::unique_ptr<MediaCodecBridge> codec, ...@@ -83,23 +83,22 @@ void DeleteMediaCodecAndSignal(std::unique_ptr<MediaCodecBridge> codec,
CodecConfig::CodecConfig() {} CodecConfig::CodecConfig() {}
CodecConfig::~CodecConfig() {} CodecConfig::~CodecConfig() {}
AVDACodecAllocator::HangDetector::HangDetector( CodecAllocator::HangDetector::HangDetector(const base::TickClock* tick_clock)
const base::TickClock* tick_clock)
: tick_clock_(tick_clock) {} : tick_clock_(tick_clock) {}
void AVDACodecAllocator::HangDetector::WillProcessTask( void CodecAllocator::HangDetector::WillProcessTask(
const base::PendingTask& pending_task) { const base::PendingTask& pending_task) {
base::AutoLock l(lock_); base::AutoLock l(lock_);
task_start_time_ = tick_clock_->NowTicks(); task_start_time_ = tick_clock_->NowTicks();
} }
void AVDACodecAllocator::HangDetector::DidProcessTask( void CodecAllocator::HangDetector::DidProcessTask(
const base::PendingTask& pending_task) { const base::PendingTask& pending_task) {
base::AutoLock l(lock_); base::AutoLock l(lock_);
task_start_time_ = base::TimeTicks(); task_start_time_ = base::TimeTicks();
} }
bool AVDACodecAllocator::HangDetector::IsThreadLikelyHung() { bool CodecAllocator::HangDetector::IsThreadLikelyHung() {
base::AutoLock l(lock_); base::AutoLock l(lock_);
if (task_start_time_.is_null()) if (task_start_time_.is_null())
return false; return false;
...@@ -109,9 +108,9 @@ bool AVDACodecAllocator::HangDetector::IsThreadLikelyHung() { ...@@ -109,9 +108,9 @@ bool AVDACodecAllocator::HangDetector::IsThreadLikelyHung() {
} }
// static // static
AVDACodecAllocator* AVDACodecAllocator::GetInstance( CodecAllocator* CodecAllocator::GetInstance(
scoped_refptr<base::SequencedTaskRunner> task_runner) { scoped_refptr<base::SequencedTaskRunner> task_runner) {
static AVDACodecAllocator* allocator = new AVDACodecAllocator( static CodecAllocator* allocator = new CodecAllocator(
base::BindRepeating(&MediaCodecBridgeImpl::CreateVideoDecoder), base::BindRepeating(&MediaCodecBridgeImpl::CreateVideoDecoder),
task_runner); task_runner);
...@@ -121,10 +120,10 @@ AVDACodecAllocator* AVDACodecAllocator::GetInstance( ...@@ -121,10 +120,10 @@ AVDACodecAllocator* AVDACodecAllocator::GetInstance(
return allocator; return allocator;
} }
void AVDACodecAllocator::StartThread(AVDACodecAllocatorClient* client) { void CodecAllocator::StartThread(CodecAllocatorClient* client) {
if (!task_runner_->RunsTasksInCurrentSequence()) { if (!task_runner_->RunsTasksInCurrentSequence()) {
task_runner_->PostTask(FROM_HERE, task_runner_->PostTask(FROM_HERE,
base::Bind(&AVDACodecAllocator::StartThread, base::BindOnce(&CodecAllocator::StartThread,
base::Unretained(this), client)); base::Unretained(this), client));
return; return;
} }
...@@ -162,10 +161,10 @@ void AVDACodecAllocator::StartThread(AVDACodecAllocatorClient* client) { ...@@ -162,10 +161,10 @@ void AVDACodecAllocator::StartThread(AVDACodecAllocatorClient* client) {
return; return;
} }
void AVDACodecAllocator::StopThread(AVDACodecAllocatorClient* client) { void CodecAllocator::StopThread(CodecAllocatorClient* client) {
if (!task_runner_->RunsTasksInCurrentSequence()) { if (!task_runner_->RunsTasksInCurrentSequence()) {
task_runner_->PostTask(FROM_HERE, task_runner_->PostTask(FROM_HERE,
base::Bind(&AVDACodecAllocator::StopThread, base::BindOnce(&CodecAllocator::StopThread,
base::Unretained(this), client)); base::Unretained(this), client));
return; return;
} }
...@@ -192,20 +191,20 @@ void AVDACodecAllocator::StopThread(AVDACodecAllocatorClient* client) { ...@@ -192,20 +191,20 @@ void AVDACodecAllocator::StopThread(AVDACodecAllocatorClient* client) {
!threads_[i]->hang_detector.IsThreadLikelyHung()) { !threads_[i]->hang_detector.IsThreadLikelyHung()) {
threads_[i]->thread.task_runner()->PostTaskAndReply( threads_[i]->thread.task_runner()->PostTaskAndReply(
FROM_HERE, base::DoNothing(), FROM_HERE, base::DoNothing(),
base::Bind(&AVDACodecAllocator::StopThreadTask, base::BindOnce(&CodecAllocator::StopThreadTask,
weak_this_factory_.GetWeakPtr(), i)); weak_this_factory_.GetWeakPtr(), i));
} }
} }
} }
// Return the task runner for tasks of type |type|. // Return the task runner for tasks of type |type|.
scoped_refptr<base::SingleThreadTaskRunner> AVDACodecAllocator::TaskRunnerFor( scoped_refptr<base::SingleThreadTaskRunner> CodecAllocator::TaskRunnerFor(
TaskType task_type) { TaskType task_type) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
return threads_[task_type]->thread.task_runner(); return threads_[task_type]->thread.task_runner();
} }
std::unique_ptr<MediaCodecBridge> AVDACodecAllocator::CreateMediaCodecSync( std::unique_ptr<MediaCodecBridge> CodecAllocator::CreateMediaCodecSync(
scoped_refptr<CodecConfig> codec_config) { scoped_refptr<CodecConfig> codec_config) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
...@@ -221,8 +220,8 @@ std::unique_ptr<MediaCodecBridge> AVDACodecAllocator::CreateMediaCodecSync( ...@@ -221,8 +220,8 @@ std::unique_ptr<MediaCodecBridge> AVDACodecAllocator::CreateMediaCodecSync(
return codec; return codec;
} }
void AVDACodecAllocator::CreateMediaCodecAsync( void CodecAllocator::CreateMediaCodecAsync(
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> codec_config) { scoped_refptr<CodecConfig> codec_config) {
if (!task_runner_->RunsTasksInCurrentSequence()) { if (!task_runner_->RunsTasksInCurrentSequence()) {
// We need to be ordered with respect to any Start/StopThread from this // We need to be ordered with respect to any Start/StopThread from this
...@@ -232,9 +231,10 @@ void AVDACodecAllocator::CreateMediaCodecAsync( ...@@ -232,9 +231,10 @@ void AVDACodecAllocator::CreateMediaCodecAsync(
// supposed to be accessed from the main thread only. // supposed to be accessed from the main thread only.
task_runner_->PostTask( task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&AVDACodecAllocator::CreateMediaCodecAsyncInternal, base::BindOnce(&CodecAllocator::CreateMediaCodecAsyncInternal,
base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), base::Unretained(this),
client, codec_config)); base::ThreadTaskRunnerHandle::Get(), client,
codec_config));
return; return;
} }
...@@ -242,9 +242,9 @@ void AVDACodecAllocator::CreateMediaCodecAsync( ...@@ -242,9 +242,9 @@ void AVDACodecAllocator::CreateMediaCodecAsync(
CreateMediaCodecAsyncInternal(task_runner_, client, codec_config); CreateMediaCodecAsyncInternal(task_runner_, client, codec_config);
} }
void AVDACodecAllocator::CreateMediaCodecAsyncInternal( void CodecAllocator::CreateMediaCodecAsyncInternal(
scoped_refptr<base::SequencedTaskRunner> client_task_runner, scoped_refptr<base::SequencedTaskRunner> client_task_runner,
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> codec_config) { scoped_refptr<CodecConfig> codec_config) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
DCHECK(client_task_runner); DCHECK(client_task_runner);
...@@ -262,7 +262,7 @@ void AVDACodecAllocator::CreateMediaCodecAsyncInternal( ...@@ -262,7 +262,7 @@ void AVDACodecAllocator::CreateMediaCodecAsyncInternal(
// Post even if it's the current thread, to avoid re-entrancy. // Post even if it's the current thread, to avoid re-entrancy.
client_task_runner->PostTask( client_task_runner->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&AVDACodecAllocatorClient::OnCodecConfigured, client, base::BindOnce(&CodecAllocatorClient::OnCodecConfigured, client,
nullptr, codec_config->surface_bundle)); nullptr, codec_config->surface_bundle));
return; return;
} }
...@@ -271,14 +271,14 @@ void AVDACodecAllocator::CreateMediaCodecAsyncInternal( ...@@ -271,14 +271,14 @@ void AVDACodecAllocator::CreateMediaCodecAsyncInternal(
task_runner.get(), FROM_HERE, task_runner.get(), FROM_HERE,
base::BindOnce(&CreateMediaCodecInternal, factory_cb_, codec_config, base::BindOnce(&CreateMediaCodecInternal, factory_cb_, codec_config,
task_type == SW_CODEC), task_type == SW_CODEC),
base::BindOnce(&AVDACodecAllocator::ForwardOrDropCodec, base::BindOnce(&CodecAllocator::ForwardOrDropCodec,
base::Unretained(this), client_task_runner, client, base::Unretained(this), client_task_runner, client,
*task_type, codec_config->surface_bundle)); *task_type, codec_config->surface_bundle));
} }
void AVDACodecAllocator::ForwardOrDropCodec( void CodecAllocator::ForwardOrDropCodec(
scoped_refptr<base::SequencedTaskRunner> client_task_runner, scoped_refptr<base::SequencedTaskRunner> client_task_runner,
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
TaskType task_type, TaskType task_type,
scoped_refptr<AVDASurfaceBundle> surface_bundle, scoped_refptr<AVDASurfaceBundle> surface_bundle,
std::unique_ptr<MediaCodecBridge> media_codec) { std::unique_ptr<MediaCodecBridge> media_codec) {
...@@ -294,14 +294,14 @@ void AVDACodecAllocator::ForwardOrDropCodec( ...@@ -294,14 +294,14 @@ void AVDACodecAllocator::ForwardOrDropCodec(
// running. That's okay; MediaCodecAndSurface will handle it. // running. That's okay; MediaCodecAndSurface will handle it.
client_task_runner->PostTask( client_task_runner->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&AVDACodecAllocator::ForwardOrDropCodecOnClientThread, base::BindOnce(&CodecAllocator::ForwardOrDropCodecOnClientThread,
base::Unretained(this), client, base::Unretained(this), client,
std::make_unique<MediaCodecAndSurface>( std::make_unique<MediaCodecAndSurface>(
std::move(media_codec), std::move(surface_bundle)))); std::move(media_codec), std::move(surface_bundle))));
} }
void AVDACodecAllocator::ForwardOrDropCodecOnClientThread( void CodecAllocator::ForwardOrDropCodecOnClientThread(
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
std::unique_ptr<MediaCodecAndSurface> codec_and_surface) { std::unique_ptr<MediaCodecAndSurface> codec_and_surface) {
// Note that if |client| has been destroyed, MediaCodecAndSurface will clean // Note that if |client| has been destroyed, MediaCodecAndSurface will clean
// up properly on the correct thread. Also note that |surface_bundle| will be // up properly on the correct thread. Also note that |surface_bundle| will be
...@@ -313,12 +313,12 @@ void AVDACodecAllocator::ForwardOrDropCodecOnClientThread( ...@@ -313,12 +313,12 @@ void AVDACodecAllocator::ForwardOrDropCodecOnClientThread(
std::move(codec_and_surface->surface_bundle)); std::move(codec_and_surface->surface_bundle));
} }
AVDACodecAllocator::MediaCodecAndSurface::MediaCodecAndSurface( CodecAllocator::MediaCodecAndSurface::MediaCodecAndSurface(
std::unique_ptr<MediaCodecBridge> codec, std::unique_ptr<MediaCodecBridge> codec,
scoped_refptr<AVDASurfaceBundle> surface) scoped_refptr<AVDASurfaceBundle> surface)
: media_codec(std::move(codec)), surface_bundle(std::move(surface)) {} : media_codec(std::move(codec)), surface_bundle(std::move(surface)) {}
AVDACodecAllocator::MediaCodecAndSurface::~MediaCodecAndSurface() { CodecAllocator::MediaCodecAndSurface::~MediaCodecAndSurface() {
// This code may be run on any thread. // This code may be run on any thread.
if (!media_codec) if (!media_codec)
...@@ -338,7 +338,7 @@ AVDACodecAllocator::MediaCodecAndSurface::~MediaCodecAndSurface() { ...@@ -338,7 +338,7 @@ AVDACodecAllocator::MediaCodecAndSurface::~MediaCodecAndSurface() {
// //
// If we can't start the thread, then ReleaseMediaCodec will free it on the // If we can't start the thread, then ReleaseMediaCodec will free it on the
// current thread. // current thread.
AVDACodecAllocator* allocator = GetInstance(nullptr); CodecAllocator* allocator = GetInstance(nullptr);
allocator->StartThread(nullptr); allocator->StartThread(nullptr);
allocator->ReleaseMediaCodec(std::move(media_codec), allocator->ReleaseMediaCodec(std::move(media_codec),
std::move(surface_bundle)); std::move(surface_bundle));
...@@ -349,7 +349,7 @@ AVDACodecAllocator::MediaCodecAndSurface::~MediaCodecAndSurface() { ...@@ -349,7 +349,7 @@ AVDACodecAllocator::MediaCodecAndSurface::~MediaCodecAndSurface() {
allocator->StopThread(nullptr); allocator->StopThread(nullptr);
} }
void AVDACodecAllocator::ReleaseMediaCodec( void CodecAllocator::ReleaseMediaCodec(
std::unique_ptr<MediaCodecBridge> media_codec, std::unique_ptr<MediaCodecBridge> media_codec,
scoped_refptr<AVDASurfaceBundle> surface_bundle) { scoped_refptr<AVDASurfaceBundle> surface_bundle) {
DCHECK(media_codec); DCHECK(media_codec);
...@@ -358,7 +358,7 @@ void AVDACodecAllocator::ReleaseMediaCodec( ...@@ -358,7 +358,7 @@ void AVDACodecAllocator::ReleaseMediaCodec(
// See CreateMediaCodecAsync // See CreateMediaCodecAsync
task_runner_->PostTask( task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&AVDACodecAllocator::ReleaseMediaCodec, base::BindOnce(&CodecAllocator::ReleaseMediaCodec,
base::Unretained(this), std::move(media_codec), base::Unretained(this), std::move(media_codec),
std::move(surface_bundle))); std::move(surface_bundle)));
return; return;
...@@ -396,13 +396,13 @@ void AVDACodecAllocator::ReleaseMediaCodec( ...@@ -396,13 +396,13 @@ void AVDACodecAllocator::ReleaseMediaCodec(
task_runner->PostTaskAndReply( task_runner->PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::Bind(&DeleteMediaCodecAndSignal, base::BindOnce(&DeleteMediaCodecAndSignal, std::move(media_codec),
base::Passed(std::move(media_codec)), released_event), released_event),
base::Bind(&AVDACodecAllocator::OnMediaCodecReleased, base::BindOnce(&CodecAllocator::OnMediaCodecReleased,
base::Unretained(this), std::move(surface_bundle))); base::Unretained(this), std::move(surface_bundle)));
} }
void AVDACodecAllocator::OnMediaCodecReleased( void CodecAllocator::OnMediaCodecReleased(
scoped_refptr<AVDASurfaceBundle> surface_bundle) { scoped_refptr<AVDASurfaceBundle> surface_bundle) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
...@@ -410,11 +410,11 @@ void AVDACodecAllocator::OnMediaCodecReleased( ...@@ -410,11 +410,11 @@ void AVDACodecAllocator::OnMediaCodecReleased(
pending_codec_releases_.erase(surface_bundle->overlay.get()); pending_codec_releases_.erase(surface_bundle->overlay.get());
} }
bool AVDACodecAllocator::IsAnyRegisteredAVDA() { bool CodecAllocator::IsAnyRegisteredAVDA() {
return !clients_.empty(); return !clients_.empty();
} }
base::Optional<TaskType> AVDACodecAllocator::TaskTypeForAllocation( base::Optional<TaskType> CodecAllocator::TaskTypeForAllocation(
bool software_codec_forbidden) { bool software_codec_forbidden) {
if (!threads_[AUTO_CODEC]->hang_detector.IsThreadLikelyHung()) if (!threads_[AUTO_CODEC]->hang_detector.IsThreadLikelyHung())
return AUTO_CODEC; return AUTO_CODEC;
...@@ -427,12 +427,11 @@ base::Optional<TaskType> AVDACodecAllocator::TaskTypeForAllocation( ...@@ -427,12 +427,11 @@ base::Optional<TaskType> AVDACodecAllocator::TaskTypeForAllocation(
return base::nullopt; return base::nullopt;
} }
base::Thread& AVDACodecAllocator::GetThreadForTesting(TaskType task_type) { base::Thread& CodecAllocator::GetThreadForTesting(TaskType task_type) {
return threads_[task_type]->thread; return threads_[task_type]->thread;
} }
bool AVDACodecAllocator::WaitForPendingReleaseForTesting( bool CodecAllocator::WaitForPendingReleaseForTesting(AndroidOverlay* overlay) {
AndroidOverlay* overlay) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (!pending_codec_releases_.count(overlay)) if (!pending_codec_releases_.count(overlay))
return true; return true;
...@@ -451,8 +450,8 @@ bool AVDACodecAllocator::WaitForPendingReleaseForTesting( ...@@ -451,8 +450,8 @@ bool AVDACodecAllocator::WaitForPendingReleaseForTesting(
return false; return false;
} }
AVDACodecAllocator::AVDACodecAllocator( CodecAllocator::CodecAllocator(
AVDACodecAllocator::CodecFactoryCB factory_cb, CodecAllocator::CodecFactoryCB factory_cb,
scoped_refptr<base::SequencedTaskRunner> task_runner, scoped_refptr<base::SequencedTaskRunner> task_runner,
const base::TickClock* tick_clock, const base::TickClock* tick_clock,
base::WaitableEvent* stop_event) base::WaitableEvent* stop_event)
...@@ -470,14 +469,14 @@ AVDACodecAllocator::AVDACodecAllocator( ...@@ -470,14 +469,14 @@ AVDACodecAllocator::AVDACodecAllocator(
"TaskType values are not ordered correctly."); "TaskType values are not ordered correctly.");
} }
AVDACodecAllocator::~AVDACodecAllocator() { CodecAllocator::~CodecAllocator() {
// Only tests should reach here. Shut down threads so that we guarantee that // Only tests should reach here. Shut down threads so that we guarantee that
// nothing will use the threads. // nothing will use the threads.
for (auto* thread : threads_) for (auto* thread : threads_)
thread->thread.Stop(); thread->thread.Stop();
} }
void AVDACodecAllocator::StopThreadTask(size_t index) { void CodecAllocator::StopThreadTask(size_t index) {
threads_[index]->thread.Stop(); threads_[index]->thread.Stop();
// Signal the stop event after both threads are stopped. // Signal the stop event after both threads are stopped.
if (stop_event_for_testing_ && !threads_[AUTO_CODEC]->thread.IsRunning() && if (stop_event_for_testing_ && !threads_[AUTO_CODEC]->thread.IsRunning() &&
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef MEDIA_GPU_ANDROID_AVDA_CODEC_ALLOCATOR_H_ #ifndef MEDIA_GPU_ANDROID_CODEC_ALLOCATOR_H_
#define MEDIA_GPU_ANDROID_AVDA_CODEC_ALLOCATOR_H_ #define MEDIA_GPU_ANDROID_CODEC_ALLOCATOR_H_
#include <stddef.h> #include <stddef.h>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
namespace media { namespace media {
// For TaskRunnerFor. These are used as vector indices, so please update // For TaskRunnerFor. These are used as vector indices, so please update
// AVDACodecAllocator's constructor if you add / change them. // CodecAllocator's constructor if you add / change them.
enum TaskType { enum TaskType {
// Task for an autodetected MediaCodec instance. // Task for an autodetected MediaCodec instance.
AUTO_CODEC = 0, AUTO_CODEC = 0,
...@@ -104,7 +104,7 @@ class AVDASurfaceAllocatorClient { ...@@ -104,7 +104,7 @@ class AVDASurfaceAllocatorClient {
~AVDASurfaceAllocatorClient() {} ~AVDASurfaceAllocatorClient() {}
}; };
class AVDACodecAllocatorClient { class CodecAllocatorClient {
public: public:
// Called on the main thread when a new MediaCodec is configured. // Called on the main thread when a new MediaCodec is configured.
// |media_codec| will be null if configuration failed. // |media_codec| will be null if configuration failed.
...@@ -113,16 +113,16 @@ class AVDACodecAllocatorClient { ...@@ -113,16 +113,16 @@ class AVDACodecAllocatorClient {
scoped_refptr<AVDASurfaceBundle> surface_bundle) = 0; scoped_refptr<AVDASurfaceBundle> surface_bundle) = 0;
protected: protected:
~AVDACodecAllocatorClient() {} ~CodecAllocatorClient() {}
}; };
// AVDACodecAllocator manages threads for allocating and releasing MediaCodec // CodecAllocator manages threads for allocating and releasing MediaCodec
// instances. These activities can hang, depending on android version, due // instances. These activities can hang, depending on android version, due
// to mediaserver bugs. AVDACodecAllocator detects these cases, and reports // to mediaserver bugs. CodecAllocator detects these cases, and reports
// on them to allow software fallback if the HW path is hung up. // on them to allow software fallback if the HW path is hung up.
class MEDIA_GPU_EXPORT AVDACodecAllocator { class MEDIA_GPU_EXPORT CodecAllocator {
public: public:
static AVDACodecAllocator* GetInstance( static CodecAllocator* GetInstance(
scoped_refptr<base::SequencedTaskRunner> task_runner); scoped_refptr<base::SequencedTaskRunner> task_runner);
using CodecFactoryCB = using CodecFactoryCB =
...@@ -141,8 +141,8 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -141,8 +141,8 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Make sure the construction threads are started for |client|. If the // Make sure the construction threads are started for |client|. If the
// threads fail to start, then codec allocation may fail. // threads fail to start, then codec allocation may fail.
virtual void StartThread(AVDACodecAllocatorClient* client); virtual void StartThread(CodecAllocatorClient* client);
virtual void StopThread(AVDACodecAllocatorClient* client); virtual void StopThread(CodecAllocatorClient* client);
// Create and configure a MediaCodec synchronously. // Create and configure a MediaCodec synchronously.
virtual std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync( virtual std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync(
...@@ -150,8 +150,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -150,8 +150,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Create and configure a MediaCodec asynchronously. The result is delivered // Create and configure a MediaCodec asynchronously. The result is delivered
// via OnCodecConfigured(). // via OnCodecConfigured().
virtual void CreateMediaCodecAsync( virtual void CreateMediaCodecAsync(base::WeakPtr<CodecAllocatorClient> client,
base::WeakPtr<AVDACodecAllocatorClient> client,
scoped_refptr<CodecConfig> codec_config); scoped_refptr<CodecConfig> codec_config);
// Asynchronously release |media_codec| with the attached surface. We will // Asynchronously release |media_codec| with the attached surface. We will
...@@ -177,11 +176,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -177,11 +176,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
protected: protected:
// |tick_clock| and |stop_event| are for tests only. // |tick_clock| and |stop_event| are for tests only.
AVDACodecAllocator(AVDACodecAllocator::CodecFactoryCB factory_cb, CodecAllocator(CodecAllocator::CodecFactoryCB factory_cb,
scoped_refptr<base::SequencedTaskRunner> task_runner, scoped_refptr<base::SequencedTaskRunner> task_runner,
const base::TickClock* tick_clock = nullptr, const base::TickClock* tick_clock = nullptr,
base::WaitableEvent* stop_event = nullptr); base::WaitableEvent* stop_event = nullptr);
virtual ~AVDACodecAllocator(); virtual ~CodecAllocator();
// Struct to own a codec and surface bundle, with a custom deleter to post // Struct to own a codec and surface bundle, with a custom deleter to post
// destruction to the right thread. // destruction to the right thread.
...@@ -199,7 +198,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -199,7 +198,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// It may only reference |client| from |client_task_runner|. // It may only reference |client| from |client_task_runner|.
void ForwardOrDropCodec( void ForwardOrDropCodec(
scoped_refptr<base::SequencedTaskRunner> client_task_runner, scoped_refptr<base::SequencedTaskRunner> client_task_runner,
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
TaskType task_type, TaskType task_type,
scoped_refptr<AVDASurfaceBundle> surface_bundle, scoped_refptr<AVDASurfaceBundle> surface_bundle,
std::unique_ptr<MediaCodecBridge> media_codec); std::unique_ptr<MediaCodecBridge> media_codec);
...@@ -207,11 +206,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -207,11 +206,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Forward |surface_bundle| and |media_codec| to |client| on the right thread // Forward |surface_bundle| and |media_codec| to |client| on the right thread
// to access |client|. // to access |client|.
void ForwardOrDropCodecOnClientThread( void ForwardOrDropCodecOnClientThread(
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
std::unique_ptr<MediaCodecAndSurface> codec_and_surface); std::unique_ptr<MediaCodecAndSurface> codec_and_surface);
private: private:
friend class AVDACodecAllocatorTest; friend class CodecAllocatorTest;
struct OwnerRecord { struct OwnerRecord {
AVDASurfaceAllocatorClient* owner = nullptr; AVDASurfaceAllocatorClient* owner = nullptr;
...@@ -249,7 +248,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -249,7 +248,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// which it should post the reply to |client|. // which it should post the reply to |client|.
void CreateMediaCodecAsyncInternal( void CreateMediaCodecAsyncInternal(
scoped_refptr<base::SequencedTaskRunner> client_task_runner, scoped_refptr<base::SequencedTaskRunner> client_task_runner,
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> codec_config); scoped_refptr<CodecConfig> codec_config);
// Return the task type to use for a new codec allocation, or nullopt if // Return the task type to use for a new codec allocation, or nullopt if
...@@ -275,7 +274,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -275,7 +274,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
const scoped_refptr<base::SequencedTaskRunner> task_runner_; const scoped_refptr<base::SequencedTaskRunner> task_runner_;
// All registered AVDAs. // All registered AVDAs.
std::set<AVDACodecAllocatorClient*> clients_; std::set<CodecAllocatorClient*> clients_;
// Waitable events for ongoing release tasks indexed by overlay so we can // Waitable events for ongoing release tasks indexed by overlay so we can
// wait on the codec release if the surface attached to it is being destroyed. // wait on the codec release if the surface attached to it is being destroyed.
...@@ -297,11 +296,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { ...@@ -297,11 +296,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
CodecFactoryCB factory_cb_; CodecFactoryCB factory_cb_;
// For canceling pending StopThreadTask()s. // For canceling pending StopThreadTask()s.
base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_; base::WeakPtrFactory<CodecAllocator> weak_this_factory_;
DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator); DISALLOW_COPY_AND_ASSIGN(CodecAllocator);
}; };
} // namespace media } // namespace media
#endif // MEDIA_GPU_ANDROID_AVDA_CODEC_ALLOCATOR_H_ #endif // MEDIA_GPU_ANDROID_CODEC_ALLOCATOR_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include <stdint.h> #include <stdint.h>
...@@ -30,8 +30,8 @@ namespace { ...@@ -30,8 +30,8 @@ namespace {
template <typename ReturnType> template <typename ReturnType>
void RunAndSignalTask(base::WaitableEvent* event, void RunAndSignalTask(base::WaitableEvent* event,
ReturnType* return_value, ReturnType* return_value,
const base::Callback<ReturnType(void)>& cb) { base::OnceCallback<ReturnType(void)> cb) {
*return_value = cb.Run(); *return_value = std::move(cb).Run();
event->Signal(); event->Signal();
} }
...@@ -48,7 +48,7 @@ void SignalImmediately(base::WaitableEvent* event) { ...@@ -48,7 +48,7 @@ void SignalImmediately(base::WaitableEvent* event) {
} }
} // namespace } // namespace
class MockClient : public AVDACodecAllocatorClient { class MockClient : public CodecAllocatorClient {
public: public:
MockClient() MockClient()
: codec_arrived_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, : codec_arrived_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
...@@ -65,7 +65,7 @@ class MockClient : public AVDACodecAllocatorClient { ...@@ -65,7 +65,7 @@ class MockClient : public AVDACodecAllocatorClient {
codec_arrived_event_.Signal(); codec_arrived_event_.Signal();
} }
base::WeakPtr<AVDACodecAllocatorClient> GetWeakPtr() { base::WeakPtr<CodecAllocatorClient> GetWeakPtr() {
return weak_factory_.GetWeakPtr(); return weak_factory_.GetWeakPtr();
} }
...@@ -74,12 +74,12 @@ class MockClient : public AVDACodecAllocatorClient { ...@@ -74,12 +74,12 @@ class MockClient : public AVDACodecAllocatorClient {
base::WaitableEvent codec_arrived_event_; base::WaitableEvent codec_arrived_event_;
base::WeakPtrFactory<AVDACodecAllocatorClient> weak_factory_; base::WeakPtrFactory<CodecAllocatorClient> weak_factory_;
}; };
class AVDACodecAllocatorTest : public testing::Test { class CodecAllocatorTest : public testing::Test {
public: public:
AVDACodecAllocatorTest() CodecAllocatorTest()
: allocator_thread_("AllocatorThread"), : allocator_thread_("AllocatorThread"),
stop_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, stop_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED) { base::WaitableEvent::InitialState::NOT_SIGNALED) {
...@@ -87,7 +87,7 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -87,7 +87,7 @@ class AVDACodecAllocatorTest : public testing::Test {
tick_clock_.Advance(base::TimeDelta::FromSeconds(1)); tick_clock_.Advance(base::TimeDelta::FromSeconds(1));
} }
~AVDACodecAllocatorTest() override {} ~CodecAllocatorTest() override {}
// Utility fn to test out threading. // Utility fn to test out threading.
void AllocateCodec() { void AllocateCodec() {
...@@ -133,8 +133,8 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -133,8 +133,8 @@ class AVDACodecAllocatorTest : public testing::Test {
void WaitForSurfaceDestruction() { void WaitForSurfaceDestruction() {
// This may be called from any thread. // This may be called from any thread.
PostAndWait(FROM_HERE, PostAndWait(FROM_HERE,
base::Bind( base::BindOnce(
[](AVDACodecAllocator* allocator, AndroidOverlay* overlay) { [](CodecAllocator* allocator, AndroidOverlay* overlay) {
allocator->WaitForPendingReleaseForTesting(overlay); allocator->WaitForPendingReleaseForTesting(overlay);
return true; return true;
}, },
...@@ -147,23 +147,22 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -147,23 +147,22 @@ class AVDACodecAllocatorTest : public testing::Test {
// main thread. // main thread.
ASSERT_TRUE(allocator_thread_.Start()); ASSERT_TRUE(allocator_thread_.Start());
AVDACodecAllocator::CodecFactoryCB factory_cb( CodecAllocator::CodecFactoryCB factory_cb(
base::BindRepeating(&MockMediaCodecBridge::CreateVideoDecoder)); base::BindRepeating(&MockMediaCodecBridge::CreateVideoDecoder));
// Create the first allocator on the allocator thread. // Create the first allocator on the allocator thread.
allocator_ = PostAndWait( allocator_ = PostAndWait(
FROM_HERE, base::Bind( FROM_HERE,
[](AVDACodecAllocator::CodecFactoryCB factory_cb, base::BindOnce(
[](CodecAllocator::CodecFactoryCB factory_cb,
scoped_refptr<base::SequencedTaskRunner> task_runner, scoped_refptr<base::SequencedTaskRunner> task_runner,
const base::TickClock* clock, const base::TickClock* clock, base::WaitableEvent* event) {
base::WaitableEvent* event) { return new CodecAllocator(factory_cb, task_runner, clock, event);
return new AVDACodecAllocator(factory_cb, task_runner,
clock, event);
}, },
factory_cb, allocator_thread_.task_runner(), factory_cb, allocator_thread_.task_runner(), &tick_clock_,
&tick_clock_, &stop_event_)); &stop_event_));
allocator2_ = new AVDACodecAllocator( allocator2_ =
factory_cb, base::SequencedTaskRunnerHandle::Get()); new CodecAllocator(factory_cb, base::SequencedTaskRunnerHandle::Get());
// Create a SurfaceBundle that provides an overlay. It will provide a null // Create a SurfaceBundle that provides an overlay. It will provide a null
// java ref if requested. // java ref if requested.
...@@ -179,8 +178,8 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -179,8 +178,8 @@ class AVDACodecAllocatorTest : public testing::Test {
// Don't leave any threads hung, or this will hang too. // Don't leave any threads hung, or this will hang too.
// It would be nice if we could let a unique ptr handle this, but the // It would be nice if we could let a unique ptr handle this, but the
// destructor is private. We also have to destroy it on the right thread. // destructor is private. We also have to destroy it on the right thread.
PostAndWait(FROM_HERE, base::Bind( PostAndWait(FROM_HERE, base::BindOnce(
[](AVDACodecAllocator* allocator) { [](CodecAllocator* allocator) {
delete allocator; delete allocator;
return true; return true;
}, },
...@@ -192,22 +191,22 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -192,22 +191,22 @@ class AVDACodecAllocatorTest : public testing::Test {
protected: protected:
// Start / stop the threads for |avda| on the right thread. // Start / stop the threads for |avda| on the right thread.
void StartThread(AVDACodecAllocatorClient* avda) { void StartThread(CodecAllocatorClient* avda) {
PostAndWait(FROM_HERE, base::Bind( PostAndWait(FROM_HERE,
[](AVDACodecAllocator* allocator, base::BindOnce(
AVDACodecAllocatorClient* avda) { [](CodecAllocator* allocator, CodecAllocatorClient* avda) {
allocator->StartThread(avda); allocator->StartThread(avda);
return true; // void won't work. return true; // void won't work.
}, },
allocator_, avda)); allocator_, avda));
} }
void StopThread(AVDACodecAllocatorClient* avda) { void StopThread(CodecAllocatorClient* avda) {
// Note that we also wait for the stop event, so that we know that the // Note that we also wait for the stop event, so that we know that the
// stop has completed. It's async with respect to the allocator thread. // stop has completed. It's async with respect to the allocator thread.
PostAndWait(FROM_HERE, base::Bind( PostAndWait(FROM_HERE,
[](AVDACodecAllocator* allocator, base::BindOnce(
AVDACodecAllocatorClient* avda) { [](CodecAllocator* allocator, CodecAllocatorClient* avda) {
allocator->StopThread(avda); allocator->StopThread(avda);
return true; return true;
}, },
...@@ -221,8 +220,8 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -221,8 +220,8 @@ class AVDACodecAllocatorTest : public testing::Test {
bool IsThreadRunning(TaskType task_type) { bool IsThreadRunning(TaskType task_type) {
return PostAndWait( return PostAndWait(
FROM_HERE, FROM_HERE,
base::Bind( base::BindOnce(
[](AVDACodecAllocator* allocator, TaskType task_type) { [](CodecAllocator* allocator, TaskType task_type) {
return allocator->GetThreadForTesting(task_type).IsRunning(); return allocator->GetThreadForTesting(task_type).IsRunning();
}, },
allocator_, task_type)); allocator_, task_type));
...@@ -232,14 +231,14 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -232,14 +231,14 @@ class AVDACodecAllocatorTest : public testing::Test {
bool software_codec_forbidden) { bool software_codec_forbidden) {
return PostAndWait( return PostAndWait(
FROM_HERE, FROM_HERE,
base::Bind(&AVDACodecAllocator::TaskTypeForAllocation, base::BindOnce(&CodecAllocator::TaskTypeForAllocation,
base::Unretained(allocator_), software_codec_forbidden)); base::Unretained(allocator_), software_codec_forbidden));
} }
scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerFor( scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerFor(
TaskType task_type) { TaskType task_type) {
return PostAndWait(FROM_HERE, return PostAndWait(FROM_HERE,
base::Bind(&AVDACodecAllocator::TaskRunnerFor, base::BindOnce(&CodecAllocator::TaskRunnerFor,
base::Unretained(allocator_), task_type)); base::Unretained(allocator_), task_type));
} }
...@@ -248,13 +247,13 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -248,13 +247,13 @@ class AVDACodecAllocatorTest : public testing::Test {
// be sure to return something. // be sure to return something.
template <typename ReturnType> template <typename ReturnType>
ReturnType PostAndWait(const base::Location& from_here, ReturnType PostAndWait(const base::Location& from_here,
const base::Callback<ReturnType(void)>& cb) { base::OnceCallback<ReturnType(void)> cb) {
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED); base::WaitableEvent::InitialState::NOT_SIGNALED);
ReturnType return_value = ReturnType(); ReturnType return_value = ReturnType();
allocator_thread_.task_runner()->PostTask( allocator_thread_.task_runner()->PostTask(
from_here, from_here, base::BindOnce(&RunAndSignalTask<ReturnType>, &event,
base::Bind(&RunAndSignalTask<ReturnType>, &event, &return_value, cb)); &return_value, std::move(cb)));
event.Wait(); event.Wait();
return return_value; return return_value;
} }
...@@ -272,8 +271,8 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -272,8 +271,8 @@ class AVDACodecAllocatorTest : public testing::Test {
// thread and the second one is initialized on the test thread. Each test // thread and the second one is initialized on the test thread. Each test
// should only be using one of the two. They are not unique_ptrs because the // should only be using one of the two. They are not unique_ptrs because the
// destructor is private and they need to be destructed on the right thread. // destructor is private and they need to be destructed on the right thread.
AVDACodecAllocator* allocator_ = nullptr; CodecAllocator* allocator_ = nullptr;
AVDACodecAllocator* allocator2_ = nullptr; CodecAllocator* allocator2_ = nullptr;
NiceMock<MockClient> client1_, client2_, client3_; NiceMock<MockClient> client1_, client2_, client3_;
NiceMock<MockClient>* avda1_ = &client1_; NiceMock<MockClient>* avda1_ = &client1_;
...@@ -285,7 +284,7 @@ class AVDACodecAllocatorTest : public testing::Test { ...@@ -285,7 +284,7 @@ class AVDACodecAllocatorTest : public testing::Test {
base::android::JavaRef<jobject> null_java_ref_; base::android::JavaRef<jobject> null_java_ref_;
}; };
TEST_F(AVDACodecAllocatorTest, ThreadsStartWhenClientsStart) { TEST_F(CodecAllocatorTest, ThreadsStartWhenClientsStart) {
ASSERT_FALSE(IsThreadRunning(AUTO_CODEC)); ASSERT_FALSE(IsThreadRunning(AUTO_CODEC));
ASSERT_FALSE(IsThreadRunning(SW_CODEC)); ASSERT_FALSE(IsThreadRunning(SW_CODEC));
StartThread(avda1_); StartThread(avda1_);
...@@ -293,7 +292,7 @@ TEST_F(AVDACodecAllocatorTest, ThreadsStartWhenClientsStart) { ...@@ -293,7 +292,7 @@ TEST_F(AVDACodecAllocatorTest, ThreadsStartWhenClientsStart) {
ASSERT_TRUE(IsThreadRunning(SW_CODEC)); ASSERT_TRUE(IsThreadRunning(SW_CODEC));
} }
TEST_F(AVDACodecAllocatorTest, ThreadsStopAfterAllClientsStop) { TEST_F(CodecAllocatorTest, ThreadsStopAfterAllClientsStop) {
StartThread(avda1_); StartThread(avda1_);
StartThread(avda2_); StartThread(avda2_);
StopThread(avda1_); StopThread(avda1_);
...@@ -303,7 +302,7 @@ TEST_F(AVDACodecAllocatorTest, ThreadsStopAfterAllClientsStop) { ...@@ -303,7 +302,7 @@ TEST_F(AVDACodecAllocatorTest, ThreadsStopAfterAllClientsStop) {
ASSERT_FALSE(IsThreadRunning(SW_CODEC)); ASSERT_FALSE(IsThreadRunning(SW_CODEC));
} }
TEST_F(AVDACodecAllocatorTest, TestHangThread) { TEST_F(CodecAllocatorTest, TestHangThread) {
StartThread(avda1_); StartThread(avda1_);
ASSERT_EQ(AUTO_CODEC, TaskTypeForAllocation(false)); ASSERT_EQ(AUTO_CODEC, TaskTypeForAllocation(false));
...@@ -315,7 +314,7 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) { ...@@ -315,7 +314,7 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) {
base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED); base::WaitableEvent::InitialState::NOT_SIGNALED);
TaskRunnerFor(AUTO_CODEC) TaskRunnerFor(AUTO_CODEC)
->PostTask(FROM_HERE, base::Bind(&WaitUntilRestarted, ->PostTask(FROM_HERE, base::BindOnce(&WaitUntilRestarted,
&about_to_wait_event, &wait_event)); &about_to_wait_event, &wait_event));
// Wait until the task starts, so that |allocator_| starts the hang timer. // Wait until the task starts, so that |allocator_| starts the hang timer.
about_to_wait_event.Wait(); about_to_wait_event.Wait();
...@@ -331,7 +330,7 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) { ...@@ -331,7 +330,7 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) {
base::WaitableEvent::InitialState::NOT_SIGNALED); base::WaitableEvent::InitialState::NOT_SIGNALED);
TaskRunnerFor(AUTO_CODEC) TaskRunnerFor(AUTO_CODEC)
->PostTask(FROM_HERE, ->PostTask(FROM_HERE,
base::Bind(&SignalImmediately, &done_waiting_event)); base::BindOnce(&SignalImmediately, &done_waiting_event));
wait_event.Signal(); wait_event.Signal();
done_waiting_event.Wait(); done_waiting_event.Wait();
...@@ -339,11 +338,11 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) { ...@@ -339,11 +338,11 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) {
ASSERT_EQ(AUTO_CODEC, TaskTypeForAllocation(false)); ASSERT_EQ(AUTO_CODEC, TaskTypeForAllocation(false));
} }
TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnAllocatorThread) { TEST_F(CodecAllocatorTest, AllocateAndDestroyCodecOnAllocatorThread) {
// Make sure that allocating / freeing a codec on the allocator's thread // Make sure that allocating / freeing a codec on the allocator's thread
// completes, and doesn't DCHECK. // completes, and doesn't DCHECK.
allocator_thread_.task_runner()->PostTask( allocator_thread_.task_runner()->PostTask(
FROM_HERE, base::Bind(&AVDACodecAllocatorTest::AllocateCodec, FROM_HERE, base::BindOnce(&CodecAllocatorTest::AllocateCodec,
base::Unretained(this))); base::Unretained(this)));
// Wait for the codec on this thread, rather than the allocator thread, since // Wait for the codec on this thread, rather than the allocator thread, since
...@@ -351,7 +350,7 @@ TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnAllocatorThread) { ...@@ -351,7 +350,7 @@ TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnAllocatorThread) {
avda1_->codec_arrived_event_.Wait(); avda1_->codec_arrived_event_.Wait();
allocator_thread_.task_runner()->PostTask( allocator_thread_.task_runner()->PostTask(
FROM_HERE, base::Bind(&AVDACodecAllocatorTest::DestroyCodec, FROM_HERE, base::BindOnce(&CodecAllocatorTest::DestroyCodec,
base::Unretained(this))); base::Unretained(this)));
// Note that TearDown will join |allocator_thread_|. // Note that TearDown will join |allocator_thread_|.
...@@ -361,13 +360,13 @@ TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnAllocatorThread) { ...@@ -361,13 +360,13 @@ TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnAllocatorThread) {
stop_event_.Wait(); stop_event_.Wait();
} }
TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnNewThread) { TEST_F(CodecAllocatorTest, AllocateAndDestroyCodecOnNewThread) {
// Make sure that allocating / freeing a codec on a random thread completes, // Make sure that allocating / freeing a codec on a random thread completes,
// and doesn't DCHECK. // and doesn't DCHECK.
base::Thread new_thread("NewThreadForTesting"); base::Thread new_thread("NewThreadForTesting");
ASSERT_TRUE(new_thread.Start()); ASSERT_TRUE(new_thread.Start());
new_thread.task_runner()->PostTask( new_thread.task_runner()->PostTask(
FROM_HERE, base::Bind(&AVDACodecAllocatorTest::AllocateCodec, FROM_HERE, base::BindOnce(&CodecAllocatorTest::AllocateCodec,
base::Unretained(this))); base::Unretained(this)));
// Wait for the codec on this thread, rather than |new_thread|, since that's // Wait for the codec on this thread, rather than |new_thread|, since that's
...@@ -375,7 +374,7 @@ TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnNewThread) { ...@@ -375,7 +374,7 @@ TEST_F(AVDACodecAllocatorTest, AllocateAndDestroyCodecOnNewThread) {
avda1_->codec_arrived_event_.Wait(); avda1_->codec_arrived_event_.Wait();
new_thread.task_runner()->PostTask( new_thread.task_runner()->PostTask(
FROM_HERE, base::Bind(&AVDACodecAllocatorTest::DestroyCodec, FROM_HERE, base::BindOnce(&CodecAllocatorTest::DestroyCodec,
base::Unretained(this))); base::Unretained(this)));
new_thread.Stop(); new_thread.Stop();
WaitForSurfaceDestruction(); WaitForSurfaceDestruction();
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "media/base/android/mock_media_codec_bridge.h" #include "media/base/android/mock_media_codec_bridge.h"
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -16,16 +16,16 @@ namespace media { ...@@ -16,16 +16,16 @@ namespace media {
FakeCodecAllocator::FakeCodecAllocator( FakeCodecAllocator::FakeCodecAllocator(
scoped_refptr<base::SequencedTaskRunner> task_runner) scoped_refptr<base::SequencedTaskRunner> task_runner)
: testing::NiceMock<AVDACodecAllocator>( : testing::NiceMock<CodecAllocator>(
base::BindRepeating(&MockMediaCodecBridge::CreateVideoDecoder), base::BindRepeating(&MockMediaCodecBridge::CreateVideoDecoder),
task_runner), task_runner),
most_recent_config(new CodecConfig()) {} most_recent_config(new CodecConfig()) {}
FakeCodecAllocator::~FakeCodecAllocator() = default; FakeCodecAllocator::~FakeCodecAllocator() = default;
void FakeCodecAllocator::StartThread(AVDACodecAllocatorClient* client) {} void FakeCodecAllocator::StartThread(CodecAllocatorClient* client) {}
void FakeCodecAllocator::StopThread(AVDACodecAllocatorClient* client) {} void FakeCodecAllocator::StopThread(CodecAllocatorClient* client) {}
std::unique_ptr<MediaCodecBridge> FakeCodecAllocator::CreateMediaCodecSync( std::unique_ptr<MediaCodecBridge> FakeCodecAllocator::CreateMediaCodecSync(
scoped_refptr<CodecConfig> config) { scoped_refptr<CodecConfig> config) {
...@@ -47,7 +47,7 @@ std::unique_ptr<MediaCodecBridge> FakeCodecAllocator::CreateMediaCodecSync( ...@@ -47,7 +47,7 @@ std::unique_ptr<MediaCodecBridge> FakeCodecAllocator::CreateMediaCodecSync(
} }
void FakeCodecAllocator::CreateMediaCodecAsync( void FakeCodecAllocator::CreateMediaCodecAsync(
base::WeakPtr<AVDACodecAllocatorClient> client, base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> config) { scoped_refptr<CodecConfig> config) {
// Clear |most_recent_codec| until somebody calls Provide*CodecAsync(). // Clear |most_recent_codec| until somebody calls Provide*CodecAsync().
most_recent_codec = nullptr; most_recent_codec = nullptr;
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "media/base/android/mock_media_codec_bridge.h" #include "media/base/android/mock_media_codec_bridge.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/avda_surface_bundle.h" #include "media/gpu/android/avda_surface_bundle.h"
#include "media/gpu/android/codec_allocator.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/android/surface_texture.h" #include "ui/gl/android/surface_texture.h"
...@@ -19,13 +19,13 @@ namespace media { ...@@ -19,13 +19,13 @@ namespace media {
// A codec allocator that provides a configurable fake implementation // A codec allocator that provides a configurable fake implementation
// and lets you set expecations on the "Mock*" methods. // and lets you set expecations on the "Mock*" methods.
class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> { class FakeCodecAllocator : public testing::NiceMock<CodecAllocator> {
public: public:
FakeCodecAllocator(scoped_refptr<base::SequencedTaskRunner> task_runner); FakeCodecAllocator(scoped_refptr<base::SequencedTaskRunner> task_runner);
~FakeCodecAllocator() override; ~FakeCodecAllocator() override;
void StartThread(AVDACodecAllocatorClient* client) override; void StartThread(CodecAllocatorClient* client) override;
void StopThread(AVDACodecAllocatorClient* client) override; void StopThread(CodecAllocatorClient* client) override;
// These are called with some parameters of the codec config by our // These are called with some parameters of the codec config by our
// implementation of their respective functions. This allows tests to set // implementation of their respective functions. This allows tests to set
...@@ -41,7 +41,7 @@ class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> { ...@@ -41,7 +41,7 @@ class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> {
std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync( std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync(
scoped_refptr<CodecConfig> config) override; scoped_refptr<CodecConfig> config) override;
void CreateMediaCodecAsync(base::WeakPtr<AVDACodecAllocatorClient> client, void CreateMediaCodecAsync(base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> config) override; scoped_refptr<CodecConfig> config) override;
void ReleaseMediaCodec( void ReleaseMediaCodec(
std::unique_ptr<MediaCodecBridge> media_codec, std::unique_ptr<MediaCodecBridge> media_codec,
...@@ -82,7 +82,7 @@ class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> { ...@@ -82,7 +82,7 @@ class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> {
// Whether CreateMediaCodecAsync() has been called but a codec hasn't been // Whether CreateMediaCodecAsync() has been called but a codec hasn't been
// provided yet. // provided yet.
bool codec_creation_pending_ = false; bool codec_creation_pending_ = false;
base::WeakPtr<AVDACodecAllocatorClient> client_; base::WeakPtr<CodecAllocatorClient> client_;
// The surface bundle of the pending codec creation. // The surface bundle of the pending codec creation.
scoped_refptr<AVDASurfaceBundle> pending_surface_bundle_; scoped_refptr<AVDASurfaceBundle> pending_surface_bundle_;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "media/base/video_util.h" #include "media/base/video_util.h"
#include "media/gpu/android/android_video_surface_chooser.h" #include "media/gpu/android/android_video_surface_chooser.h"
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
#if BUILDFLAG(USE_PROPRIETARY_CODECS) #if BUILDFLAG(USE_PROPRIETARY_CODECS)
...@@ -116,7 +116,7 @@ PendingDecode::~PendingDecode() = default; ...@@ -116,7 +116,7 @@ PendingDecode::~PendingDecode() = default;
MediaCodecVideoDecoder::MediaCodecVideoDecoder( MediaCodecVideoDecoder::MediaCodecVideoDecoder(
const gpu::GpuPreferences& gpu_preferences, const gpu::GpuPreferences& gpu_preferences,
DeviceInfo* device_info, DeviceInfo* device_info,
AVDACodecAllocator* codec_allocator, CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser, std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
AndroidOverlayMojoFactoryCB overlay_factory_cb, AndroidOverlayMojoFactoryCB overlay_factory_cb,
RequestOverlayInfoCB request_overlay_info_cb, RequestOverlayInfoCB request_overlay_info_cb,
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "media/base/overlay_info.h" #include "media/base/overlay_info.h"
#include "media/base/video_decoder.h" #include "media/base/video_decoder.h"
#include "media/gpu/android/android_video_surface_chooser.h" #include "media/gpu/android/android_video_surface_chooser.h"
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/codec_wrapper.h" #include "media/gpu/android/codec_wrapper.h"
#include "media/gpu/android/device_info.h" #include "media/gpu/android/device_info.h"
#include "media/gpu/android/surface_chooser_helper.h" #include "media/gpu/android/surface_chooser_helper.h"
...@@ -48,14 +48,13 @@ struct PendingDecode { ...@@ -48,14 +48,13 @@ struct PendingDecode {
// playbacks that need them. // playbacks that need them.
// TODO: Lazy initialization should be handled at a higher layer of the media // TODO: Lazy initialization should be handled at a higher layer of the media
// stack for both simplicity and cross platform support. // stack for both simplicity and cross platform support.
class MEDIA_GPU_EXPORT MediaCodecVideoDecoder class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder,
: public VideoDecoder, public CodecAllocatorClient {
public AVDACodecAllocatorClient {
public: public:
MediaCodecVideoDecoder( MediaCodecVideoDecoder(
const gpu::GpuPreferences& gpu_preferences, const gpu::GpuPreferences& gpu_preferences,
DeviceInfo* device_info, DeviceInfo* device_info,
AVDACodecAllocator* codec_allocator, CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser, std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
AndroidOverlayMojoFactoryCB overlay_factory_cb, AndroidOverlayMojoFactoryCB overlay_factory_cb,
RequestOverlayInfoCB request_overlay_info_cb, RequestOverlayInfoCB request_overlay_info_cb,
...@@ -141,7 +140,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder ...@@ -141,7 +140,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder
// Creates a codec asynchronously. // Creates a codec asynchronously.
void CreateCodec(); void CreateCodec();
// AVDACodecAllocatorClient implementation. // CodecAllocatorClient implementation.
void OnCodecConfigured( void OnCodecConfigured(
std::unique_ptr<MediaCodecBridge> media_codec, std::unique_ptr<MediaCodecBridge> media_codec,
scoped_refptr<AVDASurfaceBundle> surface_bundle) override; scoped_refptr<AVDASurfaceBundle> surface_bundle) override;
...@@ -234,7 +233,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder ...@@ -234,7 +233,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder
std::unique_ptr<CodecWrapper> codec_; std::unique_ptr<CodecWrapper> codec_;
base::ElapsedTimer idle_timer_; base::ElapsedTimer idle_timer_;
base::RepeatingTimer pump_codec_timer_; base::RepeatingTimer pump_codec_timer_;
AVDACodecAllocator* codec_allocator_; CodecAllocator* codec_allocator_;
// The current target surface that |codec_| should be rendering to. It // The current target surface that |codec_| should be rendering to. It
// reflects the latest surface choice by |surface_chooser_|. If the codec is // reflects the latest surface choice by |surface_chooser_|. If the codec is
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "media/gpu/android/android_video_decode_accelerator.h" #include "media/gpu/android/android_video_decode_accelerator.h"
#include "media/gpu/android/android_video_surface_chooser_impl.h" #include "media/gpu/android/android_video_surface_chooser_impl.h"
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/device_info.h" #include "media/gpu/android/device_info.h"
#endif #endif
#if BUILDFLAG(USE_VAAPI) #if BUILDFLAG(USE_VAAPI)
...@@ -266,7 +266,7 @@ GpuVideoDecodeAcceleratorFactory::CreateAndroidVDA( ...@@ -266,7 +266,7 @@ GpuVideoDecodeAcceleratorFactory::CreateAndroidVDA(
MediaLog* media_log) const { MediaLog* media_log) const {
std::unique_ptr<VideoDecodeAccelerator> decoder; std::unique_ptr<VideoDecodeAccelerator> decoder;
decoder.reset(new AndroidVideoDecodeAccelerator( decoder.reset(new AndroidVideoDecodeAccelerator(
AVDACodecAllocator::GetInstance(base::ThreadTaskRunnerHandle::Get()), CodecAllocator::GetInstance(base::ThreadTaskRunnerHandle::Get()),
std::make_unique<AndroidVideoSurfaceChooserImpl>( std::make_unique<AndroidVideoSurfaceChooserImpl>(
DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()), DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()),
make_context_current_cb_, get_context_group_cb_, overlay_factory_cb_, make_context_current_cb_, get_context_group_cb_, overlay_factory_cb_,
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "media/base/android/android_cdm_factory.h" #include "media/base/android/android_cdm_factory.h"
#include "media/filters/android/media_codec_audio_decoder.h" #include "media/filters/android/media_codec_audio_decoder.h"
#include "media/gpu/android/android_video_surface_chooser_impl.h" #include "media/gpu/android/android_video_surface_chooser_impl.h"
#include "media/gpu/android/avda_codec_allocator.h" #include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/media_codec_video_decoder.h" #include "media/gpu/android/media_codec_video_decoder.h"
#include "media/gpu/android/video_frame_factory_impl.h" #include "media/gpu/android/video_frame_factory_impl.h"
#include "media/mojo/interfaces/media_drm_storage.mojom.h" #include "media/mojo/interfaces/media_drm_storage.mojom.h"
...@@ -138,7 +138,7 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder( ...@@ -138,7 +138,7 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
command_buffer_id->channel_token, command_buffer_id->route_id); command_buffer_id->channel_token, command_buffer_id->route_id);
return std::make_unique<MediaCodecVideoDecoder>( return std::make_unique<MediaCodecVideoDecoder>(
gpu_preferences_, DeviceInfo::GetInstance(), gpu_preferences_, DeviceInfo::GetInstance(),
AVDACodecAllocator::GetInstance(gpu_task_runner_), CodecAllocator::GetInstance(gpu_task_runner_),
std::make_unique<AndroidVideoSurfaceChooserImpl>( std::make_unique<AndroidVideoSurfaceChooserImpl>(
DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()), DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()),
android_overlay_factory_cb_, std::move(request_overlay_info_cb), android_overlay_factory_cb_, std::move(request_overlay_info_cb),
......
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