Index: content/common/gpu/media/omx_video_decode_accelerator.h |
diff --git a/content/common/gpu/media/omx_video_decode_accelerator.h b/content/common/gpu/media/omx_video_decode_accelerator.h |
index b42a39bb04655f63699702611b62c60694da31b0..c00889f27d8c75b8210b60841fd29ef255c05999 100644 |
--- a/content/common/gpu/media/omx_video_decode_accelerator.h |
+++ b/content/common/gpu/media/omx_video_decode_accelerator.h |
@@ -15,7 +15,6 @@ |
#include "base/compiler_specific.h" |
#include "base/logging.h" |
-#include "base/memory/ref_counted.h" |
#include "base/message_loop.h" |
#include "base/shared_memory.h" |
#include "content/common/content_export.h" |
@@ -32,16 +31,15 @@ class Gles2TextureToEglImageTranslator; |
// The implementation assumes an OpenMAX IL 1.1.2 implementation conforming to |
// http://www.khronos.org/registry/omxil/specs/OpenMAX_IL_1_1_2_Specification.pdf |
// |
-// This class lives on a single thread and DCHECKs that it is never accessed |
-// from any other. OMX callbacks are trampolined from the OMX component's |
-// thread to maintain this invariant. The only exception to thread-unsafety is |
-// that references can be added from any thread (practically used only by the |
-// OMX thread). |
+// This class lives on a single thread (the GPU process ChildThread) and DCHECKs |
+// that it is never accessed from any other. OMX callbacks are trampolined from |
+// the OMX component's thread to maintain this invariant, using |weak_this()|. |
class CONTENT_EXPORT OmxVideoDecodeAccelerator : |
public media::VideoDecodeAccelerator { |
public: |
// Does not take ownership of |client| which must outlive |*this|. |
OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); |
+ virtual ~OmxVideoDecodeAccelerator(); |
// media::VideoDecodeAccelerator implementation. |
bool Initialize(media::VideoCodecProfile profile) OVERRIDE; |
@@ -51,13 +49,13 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator : |
void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
void Flush() OVERRIDE; |
void Reset() OVERRIDE; |
- void Destroy() OVERRIDE; |
+ void Destroy(bool pass_ownership) OVERRIDE; |
void SetEglState(EGLDisplay egl_display, EGLContext egl_context); |
- private: |
- virtual ~OmxVideoDecodeAccelerator(); |
+ base::WeakPtr<OmxVideoDecodeAccelerator> weak_this() { return weak_this_; } |
+ private: |
// Because OMX state-transitions are described solely by the "state reached" |
// (3.1.2.9.1, table 3-7 of the spec), we track what transition was requested |
// using this enum. Note that it is an error to request a transition while |
@@ -114,7 +112,7 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator : |
void OnReachedEOSInFlushing(); |
void OnReachedInvalidInErroring(); |
void ShutdownComponent(); |
- void BusyLoopInDestroying(); |
+ void BusyLoopInDestroying(scoped_ptr<OmxVideoDecodeAccelerator> self); |
// Port-flushing helpers. |
void FlushIOPorts(); |
@@ -138,6 +136,11 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator : |
// Decode bitstream buffers that were queued (see queued_bitstream_buffers_). |
void DecodeQueuedBitstreamBuffers(); |
+ // Weak pointer to |this|; used to safely trampoline calls from the OMX thread |
+ // to the ChildThread. Since |this| is kept alive until OMX is fully shut |
+ // down, only the OMX->Child thread direction needs to be guarded this way. |
+ base::WeakPtr<OmxVideoDecodeAccelerator> weak_this_; |
+ |
// True once Initialize() has returned true; before this point there's never a |
// point in calling client_->NotifyError(). |
bool init_begun_; |