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

Commit 5157b1e8 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "ACodec now signals an error if the mediaserver died while it is in" into jb-mr2-dev

parents c120d033 ac0230da
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ struct ACodec : public AHierarchicalStateMachine {
        kWhatInputSurfaceCreated = 'isfc',
        kWhatInputSurfaceCreated = 'isfc',
        kWhatSignaledInputEOS    = 'seos',
        kWhatSignaledInputEOS    = 'seos',
        kWhatBuffersAllocated    = 'allc',
        kWhatBuffersAllocated    = 'allc',
        kWhatOMXDied             = 'OMXd',
    };
    };


    ACodec();
    ACodec();
@@ -97,6 +98,7 @@ private:
    struct ExecutingToIdleState;
    struct ExecutingToIdleState;
    struct IdleToLoadedState;
    struct IdleToLoadedState;
    struct FlushingState;
    struct FlushingState;
    struct DeathNotifier;


    enum {
    enum {
        kWhatSetup                   = 'setu',
        kWhatSetup                   = 'setu',
+49 −8
Original line number Original line Diff line number Diff line
@@ -166,6 +166,24 @@ private:


////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////


struct ACodec::DeathNotifier : public IBinder::DeathRecipient {
    DeathNotifier(const sp<AMessage> &notify)
        : mNotify(notify) {
    }

    virtual void binderDied(const wp<IBinder> &) {
        mNotify->post();
    }

protected:
    virtual ~DeathNotifier() {}

private:
    sp<AMessage> mNotify;

    DISALLOW_EVIL_CONSTRUCTORS(DeathNotifier);
};

struct ACodec::UninitializedState : public ACodec::BaseState {
struct ACodec::UninitializedState : public ACodec::BaseState {
    UninitializedState(ACodec *codec);
    UninitializedState(ACodec *codec);


@@ -177,6 +195,8 @@ private:
    void onSetup(const sp<AMessage> &msg);
    void onSetup(const sp<AMessage> &msg);
    bool onAllocateComponent(const sp<AMessage> &msg);
    bool onAllocateComponent(const sp<AMessage> &msg);


    sp<DeathNotifier> mDeathNotifier;

    DISALLOW_EVIL_CONSTRUCTORS(UninitializedState);
    DISALLOW_EVIL_CONSTRUCTORS(UninitializedState);
};
};


@@ -2479,6 +2499,13 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) {
            return true;
            return true;
        }
        }


        case ACodec::kWhatOMXDied:
        {
            ALOGE("OMX/mediaserver died, signalling error!");
            mCodec->signalError(OMX_ErrorResourcesLost, DEAD_OBJECT);
            break;
        }

        default:
        default:
            return false;
            return false;
    }
    }
@@ -3027,6 +3054,18 @@ ACodec::UninitializedState::UninitializedState(ACodec *codec)


void ACodec::UninitializedState::stateEntered() {
void ACodec::UninitializedState::stateEntered() {
    ALOGV("Now uninitialized");
    ALOGV("Now uninitialized");

    if (mDeathNotifier != NULL) {
        mCodec->mOMX->asBinder()->unlinkToDeath(mDeathNotifier);
        mDeathNotifier.clear();
    }

    mCodec->mNativeWindow.clear();
    mCodec->mNode = NULL;
    mCodec->mOMX.clear();
    mCodec->mQuirks = 0;
    mCodec->mFlags = 0;
    mCodec->mComponentName.clear();
}
}


bool ACodec::UninitializedState::onMessageReceived(const sp<AMessage> &msg) {
bool ACodec::UninitializedState::onMessageReceived(const sp<AMessage> &msg) {
@@ -3098,6 +3137,15 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {


    sp<IOMX> omx = client.interface();
    sp<IOMX> omx = client.interface();


    sp<AMessage> notify = new AMessage(kWhatOMXDied, mCodec->id());

    mDeathNotifier = new DeathNotifier(notify);
    if (omx->asBinder()->linkToDeath(mDeathNotifier) != OK) {
        // This was a local binder, if it dies so do we, we won't care
        // about any notifications in the afterlife.
        mDeathNotifier.clear();
    }

    Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;
    Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;


    AString mime;
    AString mime;
@@ -3162,7 +3210,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
        return false;
        return false;
    }
    }


    sp<AMessage> notify = new AMessage(kWhatOMXMessage, mCodec->id());
    notify = new AMessage(kWhatOMXMessage, mCodec->id());
    observer->setNotificationMessage(notify);
    observer->setNotificationMessage(notify);


    mCodec->mComponentName = componentName;
    mCodec->mComponentName = componentName;
@@ -3216,13 +3264,6 @@ void ACodec::LoadedState::onShutdown(bool keepComponentAllocated) {
    if (!keepComponentAllocated) {
    if (!keepComponentAllocated) {
        CHECK_EQ(mCodec->mOMX->freeNode(mCodec->mNode), (status_t)OK);
        CHECK_EQ(mCodec->mOMX->freeNode(mCodec->mNode), (status_t)OK);


        mCodec->mNativeWindow.clear();
        mCodec->mNode = NULL;
        mCodec->mOMX.clear();
        mCodec->mQuirks = 0;
        mCodec->mFlags = 0;
        mCodec->mComponentName.clear();

        mCodec->changeState(mCodec->mUninitializedState);
        mCodec->changeState(mCodec->mUninitializedState);
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ struct MuxOMX : public IOMX {
    MuxOMX(const sp<IOMX> &remoteOMX);
    MuxOMX(const sp<IOMX> &remoteOMX);
    virtual ~MuxOMX();
    virtual ~MuxOMX();


    virtual IBinder *onAsBinder() { return NULL; }
    virtual IBinder *onAsBinder() { return mRemoteOMX->asBinder().get(); }


    virtual bool livesLocally(node_id node, pid_t pid);
    virtual bool livesLocally(node_id node, pid_t pid);