| Index: content/common/gpu/media/mac_video_decode_accelerator.mm
|
| diff --git a/content/common/gpu/media/mac_video_decode_accelerator.mm b/content/common/gpu/media/mac_video_decode_accelerator.mm
|
| index b10ec556e86204820c327dc63d235d1e3c405cd3..004792865e94912b224439f7d53cd4fb38e66c76 100644
|
| --- a/content/common/gpu/media/mac_video_decode_accelerator.mm
|
| +++ b/content/common/gpu/media/mac_video_decode_accelerator.mm
|
| @@ -112,7 +112,7 @@ bool MacVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile) {
|
| return false;
|
|
|
| MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
|
| - &MacVideoDecodeAccelerator::NotifyInitializeDone, this));
|
| + &MacVideoDecodeAccelerator::NotifyInitializeDone, base::AsWeakPtr(this)));
|
| return true;
|
| }
|
|
|
| @@ -134,8 +134,8 @@ void MacVideoDecodeAccelerator::Decode(
|
| if (result == content::H264Parser::kEOStream) {
|
| if (bitstream_nalu_count_.count(bitstream_buffer.id()) == 0) {
|
| MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
|
| - &MacVideoDecodeAccelerator::NotifyInputBufferRead, this,
|
| - bitstream_buffer.id()));
|
| + &MacVideoDecodeAccelerator::NotifyInputBufferRead,
|
| + base::AsWeakPtr(this), bitstream_buffer.id()));
|
| }
|
| return;
|
| }
|
| @@ -197,7 +197,7 @@ void MacVideoDecodeAccelerator::Flush() {
|
| "Call to Flush() during invalid state.", ILLEGAL_STATE,);
|
| vda_support_->Flush(true);
|
| MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
|
| - &MacVideoDecodeAccelerator::NotifyFlushDone, this));
|
| + &MacVideoDecodeAccelerator::NotifyFlushDone, base::AsWeakPtr(this)));
|
| }
|
|
|
| void MacVideoDecodeAccelerator::Reset() {
|
| @@ -206,10 +206,11 @@ void MacVideoDecodeAccelerator::Reset() {
|
| "Call to Reset() during invalid state.", ILLEGAL_STATE,);
|
| vda_support_->Flush(false);
|
| MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
|
| - &MacVideoDecodeAccelerator::NotifyResetDone, this));
|
| + &MacVideoDecodeAccelerator::NotifyResetDone, base::AsWeakPtr(this)));
|
| }
|
|
|
| -void MacVideoDecodeAccelerator::Destroy() {
|
| +void MacVideoDecodeAccelerator::Destroy(
|
| + scoped_ptr<VideoDecodeAccelerator> self) {
|
| DCHECK(CalledOnValidThread());
|
| if (vda_support_) {
|
| vda_support_->Destroy();
|
| @@ -221,7 +222,9 @@ void MacVideoDecodeAccelerator::Destroy() {
|
|
|
| MacVideoDecodeAccelerator::~MacVideoDecodeAccelerator() {
|
| DCHECK(CalledOnValidThread());
|
| - Destroy();
|
| + DCHECK(!vda_support_);
|
| + DCHECK(!client_);
|
| + DCHECK(decoded_images_.empty());
|
| }
|
|
|
| void MacVideoDecodeAccelerator::OnFrameReady(
|
| @@ -279,7 +282,7 @@ void MacVideoDecodeAccelerator::StopOnError(
|
| media::VideoDecodeAccelerator::Error error) {
|
| if (client_)
|
| client_->NotifyError(error);
|
| - Destroy();
|
| + Destroy(make_scoped_ptr<media::VideoDecodeAccelerator>(NULL));
|
| }
|
|
|
| bool MacVideoDecodeAccelerator::CreateDecoder(
|
| @@ -298,7 +301,7 @@ bool MacVideoDecodeAccelerator::CreateDecoder(
|
| PLATFORM_FAILURE, false);
|
|
|
| MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
|
| - &MacVideoDecodeAccelerator::RequestPictures, this));
|
| + &MacVideoDecodeAccelerator::RequestPictures, base::AsWeakPtr(this)));
|
| return true;
|
| }
|
|
|
| @@ -321,9 +324,9 @@ void MacVideoDecodeAccelerator::DecodeNALU(const content::H264NALU& nalu,
|
| // Keep a ref counted copy of the buffer.
|
| scoped_refptr<base::RefCountedBytes> bytes(
|
| base::RefCountedBytes::TakeVector(&data));
|
| - vda_support_->Decode(bytes->front(), bytes->size(),
|
| - base::Bind(&MacVideoDecodeAccelerator::OnFrameReady,
|
| - this, bitstream_buffer_id, bytes));
|
| + vda_support_->Decode(bytes->front(), bytes->size(), base::Bind(
|
| + &MacVideoDecodeAccelerator::OnFrameReady,
|
| + base::AsWeakPtr(this), bitstream_buffer_id, bytes));
|
| }
|
|
|
| void MacVideoDecodeAccelerator::NotifyInitializeDone() {
|
|
|