Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd962be2 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Linux Build Service Account
Browse files

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).

Conflicts:
	media/libstagefright/include/OMXNodeInstance.h
	media/libstagefright/omx/OMXNodeInstance.cpp

CRs-fixed: 1016867
Change-Id: I5f70e9b04a1d2decc7abd0d2a9588f2298519cbb
parent 6fee7bed
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ private:
    OMX::node_id mNodeID;
    OMX_HANDLETYPE mHandle;
    sp<IOMXObserver> mObserver;
    bool mDying;
    atomic_bool mDying;
    bool mIsSecure;

    // Lock only covers mGraphicBufferSource.  We can't always use mLock
+8 −5
Original line number Diff line number Diff line
@@ -198,7 +198,6 @@ OMXNodeInstance::OMXNodeInstance(
      mNodeID(0),
      mHandle(NULL),
      mObserver(observer),
      mDying(false),
      mBufferIDCount(0)
{
    mName = ADebug::GetDebugName(name);
@@ -214,6 +213,7 @@ OMXNodeInstance::OMXNodeInstance(
    mSecureBufferType[0] = kSecureBufferTypeUnknown;
    mSecureBufferType[1] = kSecureBufferTypeUnknown;
    mIsSecure = AString(name).endsWith(".secure");
    atomic_store(&mDying, false);
}

OMXNodeInstance::~OMXNodeInstance() {
@@ -270,7 +270,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);
@@ -1640,6 +1640,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);
}

@@ -1711,7 +1714,7 @@ OMX_ERRORTYPE OMXNodeInstance::OnEvent(
        return OMX_ErrorBadParameter;
    }
    OMXNodeInstance *instance = static_cast<OMXNodeInstance *>(pAppData);
    if (instance->mDying) {
    if (atomic_load(&instance->mDying)) {
        return OMX_ErrorNone;
    }
    return instance->owner()->OnEvent(
@@ -1728,7 +1731,7 @@ OMX_ERRORTYPE OMXNodeInstance::OnEmptyBufferDone(
        return OMX_ErrorBadParameter;
    }
    OMXNodeInstance *instance = static_cast<OMXNodeInstance *>(pAppData);
    if (instance->mDying) {
    if (atomic_load(&instance->mDying)) {
        return OMX_ErrorNone;
    }
    int fenceFd = instance->retrieveFenceFromMeta_l(pBuffer, kPortIndexOutput);
@@ -1746,7 +1749,7 @@ OMX_ERRORTYPE OMXNodeInstance::OnFillBufferDone(
        return OMX_ErrorBadParameter;
    }
    OMXNodeInstance *instance = static_cast<OMXNodeInstance *>(pAppData);
    if (instance->mDying) {
    if (atomic_load(&instance->mDying)) {
        return OMX_ErrorNone;
    }
    int fenceFd = instance->retrieveFenceFromMeta_l(pBuffer, kPortIndexOutput);