summaryrefslogtreecommitdiff
path: root/chromium/media/gpu/ipc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/media/gpu/ipc')
-rw-r--r--chromium/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc4
-rw-r--r--chromium/media/gpu/ipc/service/gpu_video_decode_accelerator.cc4
-rw-r--r--chromium/media/gpu/ipc/service/picture_buffer_manager.cc11
-rw-r--r--chromium/media/gpu/ipc/service/vda_video_decoder.cc64
-rw-r--r--chromium/media/gpu/ipc/service/vda_video_decoder.h62
-rw-r--r--chromium/media/gpu/ipc/service/vda_video_decoder_unittest.cc17
6 files changed, 79 insertions, 83 deletions
diff --git a/chromium/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc b/chromium/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc
index 464c10626ea..bd818a3e178 100644
--- a/chromium/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc
+++ b/chromium/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc
@@ -292,8 +292,8 @@ void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32_t error) {
// Client::NotifyError() may Destroy() |this|, so calling it needs to be the
// last thing done on this stack!
- VideoDecodeAccelerator::Client* client = nullptr;
- std::swap(client, client_);
+ VideoDecodeAccelerator::Client* client = client_;
+ client_ = nullptr;
client->NotifyError(static_cast<VideoDecodeAccelerator::Error>(error));
}
diff --git a/chromium/media/gpu/ipc/service/gpu_video_decode_accelerator.cc b/chromium/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
index efe9f6031cf..77a7881304d 100644
--- a/chromium/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
+++ b/chromium/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
@@ -121,9 +121,9 @@ class GpuVideoDecodeAccelerator::MessageFilter : public IPC::MessageFilter {
MessageFilter(GpuVideoDecodeAccelerator* owner, int32_t host_route_id)
: owner_(owner), host_route_id_(host_route_id) {}
- void OnChannelError() override { sender_ = NULL; }
+ void OnChannelError() override { sender_ = nullptr; }
- void OnChannelClosing() override { sender_ = NULL; }
+ void OnChannelClosing() override { sender_ = nullptr; }
void OnFilterAdded(IPC::Channel* channel) override { sender_ = channel; }
diff --git a/chromium/media/gpu/ipc/service/picture_buffer_manager.cc b/chromium/media/gpu/ipc/service/picture_buffer_manager.cc
index c9963a4ff87..d6164bb3820 100644
--- a/chromium/media/gpu/ipc/service/picture_buffer_manager.cc
+++ b/chromium/media/gpu/ipc/service/picture_buffer_manager.cc
@@ -218,15 +218,12 @@ class PictureBufferManagerImpl : public PictureBufferManager {
frame->set_color_space(picture.color_space());
- if (picture.allow_overlay())
- frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true);
- if (picture.read_lock_fences_enabled()) {
- frame->metadata()->SetBoolean(
- VideoFrameMetadata::READ_LOCK_FENCES_ENABLED, true);
- }
+ frame->metadata()->allow_overlay = picture.allow_overlay();
+ frame->metadata()->read_lock_fences_enabled =
+ picture.read_lock_fences_enabled();
// TODO(sandersd): Provide an API for VDAs to control this.
- frame->metadata()->SetBoolean(VideoFrameMetadata::POWER_EFFICIENT, true);
+ frame->metadata()->power_efficient = true;
return frame;
}
diff --git a/chromium/media/gpu/ipc/service/vda_video_decoder.cc b/chromium/media/gpu/ipc/service/vda_video_decoder.cc
index 5dbc5214002..f925028013a 100644
--- a/chromium/media/gpu/ipc/service/vda_video_decoder.cc
+++ b/chromium/media/gpu/ipc/service/vda_video_decoder.cc
@@ -16,6 +16,7 @@
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/config/gpu_info.h"
#include "gpu/config/gpu_preferences.h"
+#include "media/base/async_destroy_video_decoder.h"
#include "media/base/bitstream_buffer.h"
#include "media/base/decoder_buffer.h"
#include "media/base/media_log.h"
@@ -102,8 +103,7 @@ bool IsProfileSupported(
} // namespace
// static
-std::unique_ptr<VdaVideoDecoder, std::default_delete<VideoDecoder>>
-VdaVideoDecoder::Create(
+std::unique_ptr<VideoDecoder> VdaVideoDecoder::Create(
scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
std::unique_ptr<MediaLog> media_log,
@@ -111,21 +111,19 @@ VdaVideoDecoder::Create(
const gpu::GpuPreferences& gpu_preferences,
const gpu::GpuDriverBugWorkarounds& gpu_workarounds,
GetStubCB get_stub_cb) {
- // Constructed in a variable to avoid _CheckUniquePtr() PRESUBMIT.py regular
- // expressions, which do not understand custom deleters.
- // TODO(sandersd): Extend base::WrapUnique() to handle this.
- std::unique_ptr<VdaVideoDecoder, std::default_delete<VideoDecoder>> ptr(
- new VdaVideoDecoder(
- std::move(parent_task_runner), std::move(gpu_task_runner),
- std::move(media_log), target_color_space,
- base::BindOnce(&PictureBufferManager::Create),
- base::BindOnce(&CreateCommandBufferHelper, std::move(get_stub_cb)),
- base::BindRepeating(&CreateAndInitializeVda, gpu_preferences,
- gpu_workarounds),
- GpuVideoAcceleratorUtil::ConvertGpuToMediaDecodeCapabilities(
- GpuVideoDecodeAcceleratorFactory::GetDecoderCapabilities(
- gpu_preferences, gpu_workarounds))));
- return ptr;
+ auto* decoder = new VdaVideoDecoder(
+ std::move(parent_task_runner), std::move(gpu_task_runner),
+ std::move(media_log), target_color_space,
+ base::BindOnce(&PictureBufferManager::Create),
+ base::BindOnce(&CreateCommandBufferHelper, std::move(get_stub_cb)),
+ base::BindRepeating(&CreateAndInitializeVda, gpu_preferences,
+ gpu_workarounds),
+ GpuVideoAcceleratorUtil::ConvertGpuToMediaDecodeCapabilities(
+ GpuVideoDecodeAcceleratorFactory::GetDecoderCapabilities(
+ gpu_preferences, gpu_workarounds)));
+
+ return std::make_unique<AsyncDestroyVideoDecoder<VdaVideoDecoder>>(
+ base::WrapUnique(decoder));
}
VdaVideoDecoder::VdaVideoDecoder(
@@ -160,38 +158,40 @@ VdaVideoDecoder::VdaVideoDecoder(
gpu_weak_this_));
}
-void VdaVideoDecoder::Destroy() {
+void VdaVideoDecoder::DestroyAsync(std::unique_ptr<VdaVideoDecoder> decoder) {
DVLOG(1) << __func__;
- DCHECK(parent_task_runner_->BelongsToCurrentThread());
+ DCHECK(decoder);
+ DCHECK(decoder->parent_task_runner_->BelongsToCurrentThread());
- // TODO(sandersd): The documentation says that Destroy() fires any pending
- // callbacks.
+ // TODO(sandersd): The documentation says that DestroyAsync() fires any
+ // pending callbacks.
// Prevent any more callbacks to this thread.
- parent_weak_this_factory_.InvalidateWeakPtrs();
+ decoder->parent_weak_this_factory_.InvalidateWeakPtrs();
// Pass ownership of the destruction process over to the GPU thread.
- gpu_task_runner_->PostTask(
+ auto* gpu_task_runner = decoder->gpu_task_runner_.get();
+ gpu_task_runner->PostTask(
FROM_HERE,
- base::BindOnce(&VdaVideoDecoder::DestroyOnGpuThread, gpu_weak_this_));
+ base::BindOnce(&VdaVideoDecoder::CleanupOnGpuThread, std::move(decoder)));
}
-void VdaVideoDecoder::DestroyOnGpuThread() {
+void VdaVideoDecoder::CleanupOnGpuThread(
+ std::unique_ptr<VdaVideoDecoder> decoder) {
DVLOG(2) << __func__;
- DCHECK(gpu_task_runner_->BelongsToCurrentThread());
+ DCHECK(decoder);
+ DCHECK(decoder->gpu_task_runner_->BelongsToCurrentThread());
// VDA destruction is likely to result in reentrant calls to
// NotifyEndOfBitstreamBuffer(). Invalidating |gpu_weak_vda_| ensures that we
// don't call back into |vda_| during its destruction.
- gpu_weak_vda_factory_ = nullptr;
- vda_ = nullptr;
- media_log_ = nullptr;
+ decoder->gpu_weak_vda_factory_ = nullptr;
+ decoder->vda_ = nullptr;
+ decoder->media_log_ = nullptr;
// Because |parent_weak_this_| was invalidated in Destroy(), picture buffer
// dismissals since then have been dropped on the floor.
- picture_buffer_manager_->DismissAllPictureBuffers();
-
- delete this;
+ decoder->picture_buffer_manager_->DismissAllPictureBuffers();
}
VdaVideoDecoder::~VdaVideoDecoder() {
diff --git a/chromium/media/gpu/ipc/service/vda_video_decoder.h b/chromium/media/gpu/ipc/service/vda_video_decoder.h
index 07f475b7d43..72f5cf73ebb 100644
--- a/chromium/media/gpu/ipc/service/vda_video_decoder.h
+++ b/chromium/media/gpu/ipc/service/vda_video_decoder.h
@@ -64,14 +64,34 @@ class VdaVideoDecoder : public VideoDecoder,
// called on the GPU thread.
//
// See VdaVideoDecoder() for other arguments.
- static std::unique_ptr<VdaVideoDecoder, std::default_delete<VideoDecoder>>
- Create(scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
- std::unique_ptr<MediaLog> media_log,
- const gfx::ColorSpace& target_color_space,
- const gpu::GpuPreferences& gpu_preferences,
- const gpu::GpuDriverBugWorkarounds& gpu_workarounds,
- GetStubCB get_stub_cb);
+ static std::unique_ptr<VideoDecoder> Create(
+ scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
+ std::unique_ptr<MediaLog> media_log,
+ const gfx::ColorSpace& target_color_space,
+ const gpu::GpuPreferences& gpu_preferences,
+ const gpu::GpuDriverBugWorkarounds& gpu_workarounds,
+ GetStubCB get_stub_cb);
+
+ ~VdaVideoDecoder() override;
+ static void DestroyAsync(std::unique_ptr<VdaVideoDecoder>);
+
+ // media::VideoDecoder implementation.
+ std::string GetDisplayName() const override;
+ void Initialize(const VideoDecoderConfig& config,
+ bool low_delay,
+ CdmContext* cdm_context,
+ InitCB init_cb,
+ const OutputCB& output_cb,
+ const WaitingCB& waiting_cb) override;
+ void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override;
+ void Reset(base::OnceClosure reset_cb) override;
+ bool NeedsBitstreamConversion() const override;
+ bool CanReadWithoutStalling() const override;
+ int GetMaxDecodeRequests() const override;
+
+ private:
+ friend class VdaVideoDecoderTest;
// |parent_task_runner|: Task runner that |this| should operate on. All
// methods must be called on |parent_task_runner| (should be the Mojo
@@ -95,30 +115,6 @@ class VdaVideoDecoder : public VideoDecoder,
CreateAndInitializeVdaCB create_and_initialize_vda_cb,
const VideoDecodeAccelerator::Capabilities& vda_capabilities);
- // media::VideoDecoder implementation.
- std::string GetDisplayName() const override;
- void Initialize(const VideoDecoderConfig& config,
- bool low_delay,
- CdmContext* cdm_context,
- InitCB init_cb,
- const OutputCB& output_cb,
- const WaitingCB& waiting_cb) override;
- void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override;
- void Reset(base::OnceClosure reset_cb) override;
- bool NeedsBitstreamConversion() const override;
- bool CanReadWithoutStalling() const override;
- int GetMaxDecodeRequests() const override;
-
- private:
- void Destroy() override;
-
- protected:
- // Owners should call Destroy(). This is automatic via
- // std::default_delete<media::VideoDecoder> when held by a
- // std::unique_ptr<media::VideoDecoder>.
- ~VdaVideoDecoder() override;
-
- private:
// media::VideoDecodeAccelerator::Client implementation.
void NotifyInitializationComplete(Status status) override;
void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
@@ -134,7 +130,7 @@ class VdaVideoDecoder : public VideoDecoder,
void NotifyError(VideoDecodeAccelerator::Error error) override;
// Tasks and thread hopping.
- void DestroyOnGpuThread();
+ static void CleanupOnGpuThread(std::unique_ptr<VdaVideoDecoder>);
void InitializeOnGpuThread();
void ReinitializeOnGpuThread();
void InitializeDone(Status status);
diff --git a/chromium/media/gpu/ipc/service/vda_video_decoder_unittest.cc b/chromium/media/gpu/ipc/service/vda_video_decoder_unittest.cc
index 0bbf1b38a24..6bff33cdc50 100644
--- a/chromium/media/gpu/ipc/service/vda_video_decoder_unittest.cc
+++ b/chromium/media/gpu/ipc/service/vda_video_decoder_unittest.cc
@@ -16,6 +16,7 @@
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "gpu/command_buffer/common/sync_token.h"
+#include "media/base/async_destroy_video_decoder.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_buffer.h"
#include "media/base/media_util.h"
@@ -97,7 +98,7 @@ class VdaVideoDecoderTest : public testing::TestWithParam<bool> {
// In either case, vda_->Destroy() should be called once.
EXPECT_CALL(*vda_, Destroy());
- vdavd_.reset(new VdaVideoDecoder(
+ auto* vdavd = new VdaVideoDecoder(
parent_task_runner, gpu_task_runner, media_log_.Clone(),
gfx::ColorSpace(),
base::BindOnce(&VdaVideoDecoderTest::CreatePictureBufferManager,
@@ -106,8 +107,10 @@ class VdaVideoDecoderTest : public testing::TestWithParam<bool> {
base::Unretained(this)),
base::BindRepeating(&VdaVideoDecoderTest::CreateAndInitializeVda,
base::Unretained(this)),
- GetCapabilities()));
- client_ = vdavd_.get();
+ GetCapabilities());
+ vdavd_ = std::make_unique<AsyncDestroyVideoDecoder<VdaVideoDecoder>>(
+ base::WrapUnique(vdavd));
+ client_ = vdavd;
}
~VdaVideoDecoderTest() override {
@@ -137,7 +140,7 @@ class VdaVideoDecoderTest : public testing::TestWithParam<bool> {
}
void Initialize() {
- EXPECT_CALL(*vda_, Initialize(_, vdavd_.get())).WillOnce(Return(true));
+ EXPECT_CALL(*vda_, Initialize(_, client_)).WillOnce(Return(true));
EXPECT_CALL(*vda_, TryToSetupDecodeOnSeparateThread(_, _))
.WillOnce(Return(GetParam()));
EXPECT_CALL(init_cb_, Run(IsOkStatus()));
@@ -304,7 +307,7 @@ class VdaVideoDecoderTest : public testing::TestWithParam<bool> {
testing::StrictMock<MockVideoDecodeAccelerator>* vda_;
std::unique_ptr<VideoDecodeAccelerator> owned_vda_;
scoped_refptr<PictureBufferManager> pbm_;
- std::unique_ptr<VdaVideoDecoder, std::default_delete<VideoDecoder>> vdavd_;
+ std::unique_ptr<AsyncDestroyVideoDecoder<VdaVideoDecoder>> vdavd_;
VideoDecodeAccelerator::Client* client_;
uint64_t next_release_count_ = 1;
@@ -341,7 +344,7 @@ TEST_P(VdaVideoDecoderTest, Initialize_UnsupportedCodec) {
}
TEST_P(VdaVideoDecoderTest, Initialize_RejectedByVda) {
- EXPECT_CALL(*vda_, Initialize(_, vdavd_.get())).WillOnce(Return(false));
+ EXPECT_CALL(*vda_, Initialize(_, client_)).WillOnce(Return(false));
InitializeWithConfig(VideoDecoderConfig(
kCodecVP9, VP9PROFILE_PROFILE0, VideoDecoderConfig::AlphaMode::kIsOpaque,
VideoColorSpace::REC709(), kNoTransformation, gfx::Size(1920, 1088),
@@ -423,7 +426,7 @@ TEST_P(VdaVideoDecoderTest, Decode_OutputAndDismiss) {
TEST_P(VdaVideoDecoderTest, Decode_Output_MaintainsAspect) {
// Initialize with a config that has a 2:1 pixel aspect ratio.
- EXPECT_CALL(*vda_, Initialize(_, vdavd_.get())).WillOnce(Return(true));
+ EXPECT_CALL(*vda_, Initialize(_, client_)).WillOnce(Return(true));
EXPECT_CALL(*vda_, TryToSetupDecodeOnSeparateThread(_, _))
.WillOnce(Return(GetParam()));
InitializeWithConfig(VideoDecoderConfig(