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

Unified Diff: media/filters/gpu_video_decoder.cc

Issue 10852009: Clarify ownership of GpuVideoDecodeAcceleratorHost and avoid crash on context loss. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/gpu_video_decoder.cc
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc
index 848ae666c303fca1ec585b6b7d14c08188c453ed..40e8ca0a33e10f07270c190c045fd25f0f53c50a 100644
--- a/media/filters/gpu_video_decoder.cc
+++ b/media/filters/gpu_video_decoder.cc
@@ -99,18 +99,7 @@ void GpuVideoDecoder::Stop(const base::Closure& closure) {
closure.Run();
return;
}
- VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release();
- // Tricky: |this| needs to stay alive until after VDA::Destroy is actually
- // called, not just posted. We can't simply PostTaskAndReply using |closure|
- // as the |reply| because we might be called while the renderer thread
- // (a.k.a. vda_loop_proxy_) is paused (during WebMediaPlayerImpl::Destroy()),
- // which would result in an apparent hang. Instead, we take an artificial ref
- // to |this| and release it as |reply| after VDA::Destroy returns.
- AddRef();
- vda_loop_proxy_->PostTaskAndReply(
- FROM_HERE,
- base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_),
- base::Bind(&GpuVideoDecoder::Release, this));
+ DestroyVDA();
closure.Run();
}
@@ -166,10 +155,24 @@ void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream,
void GpuVideoDecoder::SetVDA(VideoDecodeAccelerator* vda) {
DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
+ DCHECK(!vda_.get());
vda_.reset(vda);
weak_vda_ = vda->AsWeakPtr();
}
+void GpuVideoDecoder::DestroyVDA() {
+ DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
+ VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release();
+ // Tricky: |this| needs to stay alive until after VDA::Destroy is actually
+ // called, not just posted, so we take an artificial ref to |this| and release
+ // it as |reply| after VDA::Destroy() returns.
+ AddRef();
+ vda_loop_proxy_->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_),
+ base::Bind(&GpuVideoDecoder::Release, this));
+}
+
void GpuVideoDecoder::Read(const ReadCB& read_cb) {
if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
@@ -542,8 +545,9 @@ void GpuVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) {
}
if (!vda_.get())
return;
- vda_loop_proxy_->DeleteSoon(FROM_HERE, vda_.release());
+
DLOG(ERROR) << "VDA Error: " << error;
+ DestroyVDA();
error_occured_ = true;
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698