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

Commit 64a388ab authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "MediaCodec: don't crash on concurrent release/start/configure"

parents aedf0b2c 2ffebfcf
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -1973,10 +1973,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {

                case kWhatComponentConfigured:
                {
                    if (mState == UNINITIALIZED || mState == INITIALIZED) {
                        // In case a kWhatError message came in and replied with error,
                    if (mState == RELEASING || mState == UNINITIALIZED || mState == INITIALIZED) {
                        // In case a kWhatError or kWhatRelease message came in and replied,
                        // we log a warning and ignore.
                        ALOGW("configure interrupted by error, current state %d", mState);
                        ALOGW("configure interrupted by error or release, current state %d",
                              mState);
                        break;
                    }
                    CHECK_EQ(mState, CONFIGURING);
@@ -2067,6 +2068,13 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {

                case kWhatStartCompleted:
                {
                    if (mState == RELEASING || mState == UNINITIALIZED) {
                        // In case a kWhatRelease message came in and replied,
                        // we log a warning and ignore.
                        ALOGW("start interrupted by release, current state %d", mState);
                        break;
                    }

                    CHECK_EQ(mState, STARTING);
                    if (mIsVideo) {
                        addResource(
@@ -2632,11 +2640,12 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                break;
            }

            // If we're flushing, or we're stopping but received a release
            // request, post the reply for the pending call first, and consider
            // it done. The reply token will be replaced after this, and we'll
            // no longer be able to reply.
            if (mState == FLUSHING || mState == STOPPING) {
            // If we're flushing, stopping, configuring or starting  but
            // received a release request, post the reply for the pending call
            // first, and consider it done. The reply token will be replaced
            // after this, and we'll no longer be able to reply.
            if (mState == FLUSHING || mState == STOPPING
                    || mState == CONFIGURING || mState == STARTING) {
                (new AMessage)->postReply(mReplyID);
            }