From c263222162f8b1b31e8bd57de2f68894782b9fce Mon Sep 17 00:00:00 2001 From: Haynes Mathew George Date: Wed, 4 Nov 2015 17:14:42 -0800 Subject: stagefright: omx: delay observer death handling Delay observer death handling to give the component a chance to observe pending freeNode (in other words, allow component to observe mDying = true). Change-Id: I5f70e9b04a1d2decc7abd0d2a9588f2298519cbb --- media/libstagefright/omx/OMXNodeInstance.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'media/libstagefright/omx/OMXNodeInstance.cpp') diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp index 8687ba3..8c949cb 100644 --- a/media/libstagefright/omx/OMXNodeInstance.cpp +++ b/media/libstagefright/omx/OMXNodeInstance.cpp @@ -193,7 +193,6 @@ OMXNodeInstance::OMXNodeInstance( mNodeID(0), mHandle(NULL), mObserver(observer), - mDying(false), mBufferIDCount(0) { mName = ADebug::GetDebugName(name); @@ -207,6 +206,7 @@ OMXNodeInstance::OMXNodeInstance( mMetadataType[0] = kMetadataBufferTypeInvalid; mMetadataType[1] = kMetadataBufferTypeInvalid; mIsSecure = AString(name).endsWith(".secure"); + atomic_store(&mDying, false); } OMXNodeInstance::~OMXNodeInstance() { @@ -277,7 +277,7 @@ status_t OMXNodeInstance::freeNode(OMXMaster *master) { // The code below may trigger some more events to be dispatched // by the OMX component - we want to ignore them as our client // does not expect them. - mDying = true; + atomic_store(&mDying, true); OMX_STATETYPE state; CHECK_EQ(OMX_GetState(mHandle, &state), OMX_ErrorNone); @@ -1461,6 +1461,9 @@ void OMXNodeInstance::onObserverDied(OMXMaster *master) { ALOGE("!!! Observer died. Quickly, do something, ... anything..."); // Try to force shutdown of the node and hope for the best. + // But allow the component to observe mDying = true first + atomic_store(&mDying, true); + sleep(2); freeNode(master); } @@ -1528,7 +1531,7 @@ OMX_ERRORTYPE OMXNodeInstance::OnEvent( OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) { OMXNodeInstance *instance = static_cast(pAppData); - if (instance->mDying) { + if (atomic_load(&instance->mDying)) { return OMX_ErrorNone; } return instance->owner()->OnEvent( @@ -1541,7 +1544,7 @@ OMX_ERRORTYPE OMXNodeInstance::OnEmptyBufferDone( OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) { OMXNodeInstance *instance = static_cast(pAppData); - if (instance->mDying) { + if (atomic_load(&instance->mDying)) { return OMX_ErrorNone; } int fenceFd = instance->retrieveFenceFromMeta_l(pBuffer, kPortIndexOutput); @@ -1555,7 +1558,7 @@ OMX_ERRORTYPE OMXNodeInstance::OnFillBufferDone( OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) { OMXNodeInstance *instance = static_cast(pAppData); - if (instance->mDying) { + if (atomic_load(&instance->mDying)) { return OMX_ErrorNone; } int fenceFd = instance->retrieveFenceFromMeta_l(pBuffer, kPortIndexOutput); -- cgit v1.1