diff options
author | Haynes Mathew George <hgeorge@codeaurora.org> | 2015-11-04 17:14:42 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-30 18:58:53 -0800 |
commit | c263222162f8b1b31e8bd57de2f68894782b9fce (patch) | |
tree | c8344942faeb9046062b910b88a4f1181f0253d2 /media/libstagefright/omx/OMXNodeInstance.cpp | |
parent | d15a8bd157cb531716bd3e15561f557e74588801 (diff) | |
download | frameworks_av-c263222162f8b1b31e8bd57de2f68894782b9fce.zip frameworks_av-c263222162f8b1b31e8bd57de2f68894782b9fce.tar.gz frameworks_av-c263222162f8b1b31e8bd57de2f68894782b9fce.tar.bz2 |
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
Diffstat (limited to 'media/libstagefright/omx/OMXNodeInstance.cpp')
-rw-r--r-- | media/libstagefright/omx/OMXNodeInstance.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
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<OMXNodeInstance *>(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<OMXNodeInstance *>(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<OMXNodeInstance *>(pAppData); - if (instance->mDying) { + if (atomic_load(&instance->mDying)) { return OMX_ErrorNone; } int fenceFd = instance->retrieveFenceFromMeta_l(pBuffer, kPortIndexOutput); |