Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc

Issue 2627173002: Adds locks for CommandBufferProxyImpl invalidation (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc
diff --git a/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc b/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc
index 94d53179e207707debf6a7cd2b11cbc96dab5ddd..7f832b41faceaa68a4473c36096e1d74f3580487 100644
--- a/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc
+++ b/media/gpu/ipc/client/gpu_video_decode_accelerator_host.cc
@@ -20,8 +20,9 @@ GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost(
gpu::CommandBufferProxyImpl* impl)
: channel_(impl->channel()),
decoder_route_id_(MSG_ROUTING_NONE),
- client_(NULL),
+ client_(nullptr),
impl_(impl),
+ media_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_this_factory_(this) {
DCHECK(channel_);
DCHECK(impl_);
@@ -33,6 +34,8 @@ GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() {
if (channel_ && decoder_route_id_ != MSG_ROUTING_NONE)
channel_->RemoveRoute(decoder_route_id_);
+
+ base::AutoLock lock(impl_lock_);
if (impl_)
impl_->RemoveDeletionObserver(this);
}
@@ -68,7 +71,7 @@ void GpuVideoDecodeAcceleratorHost::OnChannelError() {
if (channel_) {
if (decoder_route_id_ != MSG_ROUTING_NONE)
channel_->RemoveRoute(decoder_route_id_);
- channel_ = NULL;
+ channel_ = nullptr;
}
DLOG(ERROR) << "OnChannelError()";
PostNotifyError(PLATFORM_FAILURE);
@@ -79,6 +82,7 @@ bool GpuVideoDecodeAcceleratorHost::Initialize(const Config& config,
DCHECK(CalledOnValidThread());
client_ = client;
+ base::AutoLock lock(impl_lock_);
if (!impl_)
return false;
@@ -175,22 +179,24 @@ void GpuVideoDecodeAcceleratorHost::Destroy() {
DCHECK(CalledOnValidThread());
if (channel_)
Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_));
- client_ = NULL;
+ client_ = nullptr;
delete this;
}
void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() {
- DCHECK(CalledOnValidThread());
- impl_ = NULL;
+ base::AutoLock lock(impl_lock_);
+ impl_ = nullptr;
// The gpu::CommandBufferProxyImpl is going away; error out this VDA.
- OnChannelError();
+ media_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&GpuVideoDecodeAcceleratorHost::OnChannelError,
+ weak_this_factory_.GetWeakPtr()));
}
void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) {
DCHECK(CalledOnValidThread());
DVLOG(2) << "PostNotifyError(): error=" << error;
- base::ThreadTaskRunnerHandle::Get()->PostTask(
+ media_task_runner_->PostTask(
FROM_HERE, base::Bind(&GpuVideoDecodeAcceleratorHost::OnNotifyError,
weak_this_factory_.GetWeakPtr(), error));
}
@@ -280,7 +286,7 @@ 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 = NULL;
+ VideoDecodeAccelerator::Client* client = nullptr;
std::swap(client, client_);
client->NotifyError(static_cast<VideoDecodeAccelerator::Error>(error));
}
« no previous file with comments | « media/gpu/ipc/client/gpu_video_decode_accelerator_host.h ('k') | media/gpu/ipc/client/gpu_video_encode_accelerator_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698