| 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..e5bca0dfb02abb5581127188c8aa17e314f1b213 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, weak_vda_));
|
| }
|
|
|
| void GpuVideoDecoder::Stop(const base::Closure& closure) {
|
| @@ -103,13 +103,13 @@ void GpuVideoDecoder::Stop(const base::Closure& closure) {
|
| &GpuVideoDecoder::Stop, this, closure));
|
| return;
|
| }
|
| - if (!vda_) {
|
| + if (!vda_.get()) {
|
| closure.Run();
|
| return;
|
| }
|
| + VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release();
|
| vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
|
| - &VideoDecodeAccelerator::Destroy, vda_));
|
| - vda_ = NULL;
|
| + &VideoDecodeAccelerator::Destroy, weak_vda_));
|
| closure.Run();
|
| }
|
|
|
| @@ -141,8 +141,9 @@ void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream,
|
| return;
|
| }
|
|
|
| - vda_ = factories_->CreateVideoDecodeAccelerator(config.profile(), this);
|
| - if (!vda_) {
|
| + VideoDecodeAccelerator* vda =
|
| + factories_->CreateVideoDecodeAccelerator(config.profile(), this);
|
| + if (!vda) {
|
| status_cb.Run(DECODER_ERROR_NOT_SUPPORTED);
|
| return;
|
| }
|
| @@ -156,7 +157,16 @@ void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream,
|
| config_frame_duration_ = GetFrameDuration(config);
|
|
|
| DVLOG(1) << "GpuVideoDecoder::Initialize() succeeded.";
|
| - status_cb.Run(PIPELINE_OK);
|
| + vda_loop_proxy_->PostTaskAndReply(
|
| + FROM_HERE,
|
| + base::Bind(&GpuVideoDecoder::SetVDA, this, vda),
|
| + base::Bind(status_cb, PIPELINE_OK));
|
| +}
|
| +
|
| +void GpuVideoDecoder::SetVDA(VideoDecodeAccelerator* vda) {
|
| + DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + vda_.reset(vda);
|
| + weak_vda_ = vda->AsWeakPtr();
|
| }
|
|
|
| void GpuVideoDecoder::Read(const ReadCB& read_cb) {
|
| @@ -171,7 +181,7 @@ void GpuVideoDecoder::Read(const ReadCB& read_cb) {
|
| return;
|
| }
|
|
|
| - if (!vda_) {
|
| + if (!vda_.get()) {
|
| read_cb.Run(kOk, VideoFrame::CreateEmptyFrame());
|
| return;
|
| }
|
| @@ -218,7 +228,7 @@ void GpuVideoDecoder::RequestBufferDecode(
|
| return;
|
| }
|
|
|
| - if (!vda_) {
|
| + if (!vda_.get()) {
|
| EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame());
|
| return;
|
| }
|
| @@ -227,7 +237,7 @@ void GpuVideoDecoder::RequestBufferDecode(
|
| if (state_ == kNormal) {
|
| state_ = kDrainingDecoder;
|
| vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
|
| - &VideoDecodeAccelerator::Flush, vda_));
|
| + &VideoDecodeAccelerator::Flush, weak_vda_));
|
| }
|
| return;
|
| }
|
| @@ -243,7 +253,7 @@ void GpuVideoDecoder::RequestBufferDecode(
|
| RecordBufferTimeData(bitstream_buffer, *buffer);
|
|
|
| vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
|
| - &VideoDecodeAccelerator::Decode, vda_, bitstream_buffer));
|
| + &VideoDecodeAccelerator::Decode, weak_vda_, bitstream_buffer));
|
| }
|
|
|
| void GpuVideoDecoder::RecordBufferTimeData(
|
| @@ -319,7 +329,7 @@ void GpuVideoDecoder::ProvidePictureBuffers(uint32 count,
|
| return;
|
| }
|
|
|
| - if (!vda_)
|
| + if (!vda_.get())
|
| return;
|
|
|
| std::vector<PictureBuffer> picture_buffers;
|
| @@ -331,7 +341,8 @@ void GpuVideoDecoder::ProvidePictureBuffers(uint32 count,
|
| DCHECK(inserted);
|
| }
|
| vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
|
| - &VideoDecodeAccelerator::AssignPictureBuffers, vda_, picture_buffers));
|
| + &VideoDecodeAccelerator::AssignPictureBuffers, weak_vda_,
|
| + picture_buffers));
|
| }
|
|
|
| void GpuVideoDecoder::DismissPictureBuffer(int32 id) {
|
| @@ -409,10 +420,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, weak_vda_,
|
| + picture_buffer_id));
|
| }
|
|
|
| GpuVideoDecoder::SHMBuffer* GpuVideoDecoder::GetSHM(size_t min_size) {
|
| @@ -467,7 +479,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 +522,7 @@ void GpuVideoDecoder::NotifyResetDone() {
|
| return;
|
| }
|
|
|
| - if (!vda_)
|
| + if (!vda_.get())
|
| return;
|
|
|
| DCHECK(ready_video_frames_.empty());
|
| @@ -532,9 +544,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;
|
|
|