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

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 10827090: Delay deleting GpuVideoDecoder until after GpuVideoDecodeAcceleratorHost::Destroy() fires. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { 100 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
101 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 101 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
102 &GpuVideoDecoder::Stop, this, closure)); 102 &GpuVideoDecoder::Stop, this, closure));
103 return; 103 return;
104 } 104 }
105 if (!vda_.get()) { 105 if (!vda_.get()) {
106 closure.Run(); 106 closure.Run();
107 return; 107 return;
108 } 108 }
109 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release(); 109 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release();
110 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( 110 // Tricky: |this| needs to stay alive until after VDA::Destroy is actually
111 &VideoDecodeAccelerator::Destroy, weak_vda_)); 111 // called, not just posted. We can't simply PostTaskAndReply using |closure|
112 // as the |reply| because we might be called while the renderer thread
113 // (a.k.a. vda_loop_proxy_) is paused (during WebMediaPlayerImpl::Destroy()),
114 // which would result in an apparent hang. Instead, we take an artificial ref
115 // to |this| and release it as |reply| after VDA::Destroy returns.
116 AddRef();
117 vda_loop_proxy_->PostTaskAndReply(
118 FROM_HERE,
119 base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_),
120 base::Bind(&GpuVideoDecoder::Release, this));
112 closure.Run(); 121 closure.Run();
113 } 122 }
114 123
115 void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, 124 void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream,
116 const PipelineStatusCB& orig_status_cb, 125 const PipelineStatusCB& orig_status_cb,
117 const StatisticsCB& statistics_cb) { 126 const StatisticsCB& statistics_cb) {
118 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { 127 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
119 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 128 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
120 &GpuVideoDecoder::Initialize, 129 &GpuVideoDecoder::Initialize,
121 this, stream, orig_status_cb, statistics_cb)); 130 this, stream, orig_status_cb, statistics_cb));
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 567
559 error_occured_ = true; 568 error_occured_ = true;
560 569
561 if (!pending_read_cb_.is_null()) { 570 if (!pending_read_cb_.is_null()) {
562 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 571 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
563 return; 572 return;
564 } 573 }
565 } 574 }
566 575
567 } // namespace media 576 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698