Index: media/filters/gpu_video_decoder.cc |
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc |
index 7415db87ac0bb4b4513313a1683fbfc82ea49a8c..fa68dbf885f0819bd75099307198b4cfe9d379c4 100644 |
--- a/media/filters/gpu_video_decoder.cc |
+++ b/media/filters/gpu_video_decoder.cc |
@@ -72,7 +72,7 @@ void GpuVideoDecoder::Reset(const base::Closure& closure) { |
// Throw away any already-decoded, not-yet-delivered frames. |
ready_video_frames_.clear(); |
- if (!vda_) { |
+ if (!vda_.get()) { |
closure.Run(); |
return; |
} |
@@ -94,7 +94,7 @@ void GpuVideoDecoder::Reset(const base::Closure& closure) { |
} |
vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
- &VideoDecodeAccelerator::Reset, vda_)); |
+ &VideoDecodeAccelerator::Reset, vda_->AsWeakPtr())); |
Ryan Sleevi
2012/07/16 21:26:07
Now, you're posing vda_ as a WeakPtr to vda_loop_p
Ami GONE FROM CHROMIUM
2012/07/16 21:31:58
Blort, you were too quick for me.
This file in rie
|
} |
void GpuVideoDecoder::Stop(const base::Closure& closure) { |
@@ -103,13 +103,14 @@ void GpuVideoDecoder::Stop(const base::Closure& closure) { |
&GpuVideoDecoder::Stop, this, closure)); |
return; |
} |
- if (!vda_) { |
+ if (!vda_.get()) { |
closure.Run(); |
return; |
} |
+ VideoDecodeAccelerator* vda = vda_.get(); |
vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
- &VideoDecodeAccelerator::Destroy, vda_)); |
- vda_ = NULL; |
+ &VideoDecodeAccelerator::Destroy, base::Unretained(vda), |
+ base::Passed(&vda_))); |
closure.Run(); |
} |
@@ -141,8 +142,8 @@ void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, |
return; |
} |
- vda_ = factories_->CreateVideoDecodeAccelerator(config.profile(), this); |
- if (!vda_) { |
+ vda_.reset(factories_->CreateVideoDecodeAccelerator(config.profile(), this)); |
+ if (!vda_.get()) { |
status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
return; |
} |
@@ -171,7 +172,7 @@ void GpuVideoDecoder::Read(const ReadCB& read_cb) { |
return; |
} |
- if (!vda_) { |
+ if (!vda_.get()) { |
read_cb.Run(kOk, VideoFrame::CreateEmptyFrame()); |
return; |
} |
@@ -218,7 +219,7 @@ void GpuVideoDecoder::RequestBufferDecode( |
return; |
} |
- if (!vda_) { |
+ if (!vda_.get()) { |
EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame()); |
return; |
} |
@@ -227,7 +228,7 @@ void GpuVideoDecoder::RequestBufferDecode( |
if (state_ == kNormal) { |
state_ = kDrainingDecoder; |
vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
- &VideoDecodeAccelerator::Flush, vda_)); |
+ &VideoDecodeAccelerator::Flush, vda_->AsWeakPtr())); |
} |
return; |
} |
@@ -243,7 +244,7 @@ void GpuVideoDecoder::RequestBufferDecode( |
RecordBufferTimeData(bitstream_buffer, *buffer); |
vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
- &VideoDecodeAccelerator::Decode, vda_, bitstream_buffer)); |
+ &VideoDecodeAccelerator::Decode, vda_->AsWeakPtr(), bitstream_buffer)); |
} |
void GpuVideoDecoder::RecordBufferTimeData( |
@@ -319,7 +320,7 @@ void GpuVideoDecoder::ProvidePictureBuffers(uint32 count, |
return; |
} |
- if (!vda_) |
+ if (!vda_.get()) |
return; |
std::vector<PictureBuffer> picture_buffers; |
@@ -331,7 +332,8 @@ void GpuVideoDecoder::ProvidePictureBuffers(uint32 count, |
DCHECK(inserted); |
} |
vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
- &VideoDecodeAccelerator::AssignPictureBuffers, vda_, picture_buffers)); |
+ &VideoDecodeAccelerator::AssignPictureBuffers, vda_->AsWeakPtr(), |
+ picture_buffers)); |
} |
void GpuVideoDecoder::DismissPictureBuffer(int32 id) { |
@@ -409,10 +411,11 @@ void GpuVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id) { |
&GpuVideoDecoder::ReusePictureBuffer, this, picture_buffer_id)); |
return; |
} |
- if (!vda_) |
+ if (!vda_.get()) |
return; |
vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
- &VideoDecodeAccelerator::ReusePictureBuffer, vda_, picture_buffer_id)); |
+ &VideoDecodeAccelerator::ReusePictureBuffer, vda_->AsWeakPtr(), |
+ picture_buffer_id)); |
} |
GpuVideoDecoder::SHMBuffer* GpuVideoDecoder::GetSHM(size_t min_size) { |
@@ -467,7 +470,7 @@ void GpuVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { |
} |
GpuVideoDecoder::~GpuVideoDecoder() { |
- DCHECK(!vda_); // Stop should have been already called. |
+ DCHECK(!vda_.get()); // Stop should have been already called. |
DCHECK(pending_read_cb_.is_null()); |
for (size_t i = 0; i < available_shm_segments_.size(); ++i) { |
available_shm_segments_[i]->shm->Close(); |
@@ -510,7 +513,7 @@ void GpuVideoDecoder::NotifyResetDone() { |
return; |
} |
- if (!vda_) |
+ if (!vda_.get()) |
return; |
DCHECK(ready_video_frames_.empty()); |
@@ -532,9 +535,9 @@ void GpuVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) { |
&GpuVideoDecoder::NotifyError, this, error)); |
return; |
} |
- if (!vda_) |
+ if (!vda_.get()) |
return; |
- vda_ = NULL; |
+ vda_loop_proxy_->DeleteSoon(FROM_HERE, vda_.release()); |
DLOG(ERROR) << "VDA Error: " << error; |
error_occured_ = true; |