| OLD | NEW |
| 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/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 base::WeakPtrFactory<VideoDecodeAccelerator::Client> weak_client_factory_; | 62 base::WeakPtrFactory<VideoDecodeAccelerator::Client> weak_client_factory_; |
| 63 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client_; | 63 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(VDAClientProxy); | 65 DISALLOW_COPY_AND_ASSIGN(VDAClientProxy); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 VDAClientProxy::VDAClientProxy(VideoDecodeAccelerator::Client* client) | 68 VDAClientProxy::VDAClientProxy(VideoDecodeAccelerator::Client* client) |
| 69 : client_loop_(base::MessageLoopProxy::current()), | 69 : client_loop_(base::MessageLoopProxy::current()), |
| 70 weak_client_factory_(client), | 70 weak_client_factory_(client), |
| 71 weak_client_(weak_client_factory_.GetWeakPtr()) { | 71 weak_client_(weak_client_factory_.GetWeakPtr()) { |
| 72 DCHECK(weak_client_); | 72 DCHECK(weak_client_.get()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 VDAClientProxy::~VDAClientProxy() {} | 75 VDAClientProxy::~VDAClientProxy() {} |
| 76 | 76 |
| 77 void VDAClientProxy::Detach() { | 77 void VDAClientProxy::Detach() { |
| 78 DCHECK(client_loop_->BelongsToCurrentThread()); | 78 DCHECK(client_loop_->BelongsToCurrentThread()); |
| 79 DCHECK(weak_client_) << "Detach() already called"; | 79 DCHECK(weak_client_.get()) << "Detach() already called"; |
| 80 weak_client_factory_.InvalidateWeakPtrs(); | 80 weak_client_factory_.InvalidateWeakPtrs(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void VDAClientProxy::NotifyInitializeDone() { | 83 void VDAClientProxy::NotifyInitializeDone() { |
| 84 client_loop_->PostTask(FROM_HERE, base::Bind( | 84 client_loop_->PostTask(FROM_HERE, base::Bind( |
| 85 &VideoDecodeAccelerator::Client::NotifyInitializeDone, weak_client_)); | 85 &VideoDecodeAccelerator::Client::NotifyInitializeDone, weak_client_)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void VDAClientProxy::ProvidePictureBuffers(uint32 count, | 88 void VDAClientProxy::ProvidePictureBuffers(uint32 count, |
| 89 const gfx::Size& size, | 89 const gfx::Size& size, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 picture_buffers_in_decoder_.begin(); | 299 picture_buffers_in_decoder_.begin(); |
| 300 it != picture_buffers_in_decoder_.end(); ++it) { | 300 it != picture_buffers_in_decoder_.end(); ++it) { |
| 301 factories_->DeleteTexture(it->second.texture_id()); | 301 factories_->DeleteTexture(it->second.texture_id()); |
| 302 } | 302 } |
| 303 picture_buffers_in_decoder_.clear(); | 303 picture_buffers_in_decoder_.clear(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 static void DestroyVDAWithClientProxy( | 306 static void DestroyVDAWithClientProxy( |
| 307 const scoped_refptr<VDAClientProxy>& client_proxy, | 307 const scoped_refptr<VDAClientProxy>& client_proxy, |
| 308 base::WeakPtr<VideoDecodeAccelerator> weak_vda) { | 308 base::WeakPtr<VideoDecodeAccelerator> weak_vda) { |
| 309 if (weak_vda) { | 309 if (weak_vda.get()) { |
| 310 weak_vda->Destroy(); | 310 weak_vda->Destroy(); |
| 311 DCHECK(!weak_vda); // Check VDA::Destroy() contract. | 311 DCHECK(!weak_vda.get()); // Check VDA::Destroy() contract. |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 void GpuVideoDecoder::DestroyVDA() { | 315 void GpuVideoDecoder::DestroyVDA() { |
| 316 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); | 316 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); |
| 317 | 317 |
| 318 // |client_proxy| must stay alive until |weak_vda_| has been destroyed. | 318 // |client_proxy| must stay alive until |weak_vda_| has been destroyed. |
| 319 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 319 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
| 320 &DestroyVDAWithClientProxy, client_proxy_, weak_vda_)); | 320 &DestroyVDAWithClientProxy, client_proxy_, weak_vda_)); |
| 321 | 321 |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 707 |
| 708 state_ = kError; | 708 state_ = kError; |
| 709 | 709 |
| 710 if (!pending_read_cb_.is_null()) { | 710 if (!pending_read_cb_.is_null()) { |
| 711 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); | 711 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); |
| 712 return; | 712 return; |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 } // namespace media | 716 } // namespace media |
| OLD | NEW |