Index: content/common/gpu/media/vaapi_video_decode_accelerator.h |
diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.h b/content/common/gpu/media/vaapi_video_decode_accelerator.h |
index 6624792c6bd9e7337a334618d074c8a0cb324021..10305f9241341a09ef05695bf80729f6096c8003 100644 |
--- a/content/common/gpu/media/vaapi_video_decode_accelerator.h |
+++ b/content/common/gpu/media/vaapi_video_decode_accelerator.h |
@@ -32,12 +32,18 @@ |
// Class to provide video decode acceleration for Intel systems with hardware |
// support for it, and on which libva is available. |
// Decoding tasks are performed in a separate decoding thread. |
+// |
+// Threading/life-cycle: this object is created & destroyed on the GPU |
+// ChildThread. A few methods on it are called on the decoder thread which is |
+// stopped during |this->Destroy()|, so any tasks posted to the decoder thread |
+// can assume |*this| is still alive. See |weak_this_| below for more details. |
class CONTENT_EXPORT VaapiVideoDecodeAccelerator : |
public media::VideoDecodeAccelerator { |
public: |
VaapiVideoDecodeAccelerator( |
Client* client, |
const base::Callback<bool(void)>& make_context_current); |
+ virtual ~VaapiVideoDecodeAccelerator(); |
// media::VideoDecodeAccelerator implementation. |
virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; |
@@ -47,14 +53,12 @@ class CONTENT_EXPORT VaapiVideoDecodeAccelerator : |
virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
virtual void Flush() OVERRIDE; |
virtual void Reset() OVERRIDE; |
- virtual void Destroy() OVERRIDE; |
+ virtual void Destroy(scoped_ptr<VideoDecodeAccelerator> self) OVERRIDE; |
// Used by user of this class to pass X/GLX state. |
void SetGlxState(Display* x_display, GLXContext glx_context); |
private: |
- virtual ~VaapiVideoDecodeAccelerator(); |
- |
// Ensure data has been synced with the output texture and notify |
// the client it is ready for displaying. |
void SyncAndNotifyPictureReady(int32 input_id, int32 output_id); |
@@ -174,6 +178,14 @@ class CONTENT_EXPORT VaapiVideoDecodeAccelerator : |
// ChildThread's message loop |
MessageLoop* message_loop_; |
+ // WeakPtr<> pointing to |this| for use in posting tasks from the decoder |
+ // thread back to the ChildThread. Because the decoder thread is a member of |
+ // this class, any task running on the decoder thread is guaranteed that this |
+ // object is still alive. As a result, tasks posted from ChildThread to |
+ // decoder thread should use base::Unretained(this), and tasks posted from the |
+ // decoder thread to the ChildThread should use |weak_this_|. |
+ base::WeakPtr<VaapiVideoDecodeAccelerator> weak_this_; |
+ |
// To expose client callbacks from VideoDecodeAccelerator. |
// NOTE: all calls to these objects *MUST* be executed on message_loop_. |
base::WeakPtrFactory<Client> client_ptr_factory_; |