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

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

Merge "Make sure MediaCodec::stop() and MediaCodec::release() still return" into jb-mr2-dev

parents da77cee9 03ddaec8
Loading
Loading
Loading
Loading
+23 −1
Original line number Original line Diff line number Diff line
@@ -534,6 +534,20 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                            // the shutdown complete notification.
                            // the shutdown complete notification.


                            sendErrorReponse = false;
                            sendErrorReponse = false;

                            if (omxError == OMX_ErrorResourcesLost
                                    && internalError == DEAD_OBJECT) {
                                // MediaServer died, there definitely won't
                                // be a shutdown complete notification after
                                // all.

                                // note that we're directly going from
                                // STOPPING->UNINITIALIZED, instead of the
                                // usual STOPPING->INITIALIZED state.
                                setState(UNINITIALIZED);

                                (new AMessage)->postReply(mReplyID);
                            }
                            break;
                            break;
                        }
                        }


@@ -1013,8 +1027,16 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {


            if (mState != INITIALIZED
            if (mState != INITIALIZED
                    && mState != CONFIGURED && mState != STARTED) {
                    && mState != CONFIGURED && mState != STARTED) {
                // We may be in "UNINITIALIZED" state already without the
                // client being aware of this if media server died while
                // we were being stopped. The client would assume that
                // after stop() returned, it would be safe to call release()
                // and it should be in this case, no harm to allow a release()
                // if we're already uninitialized.
                sp<AMessage> response = new AMessage;
                sp<AMessage> response = new AMessage;
                response->setInt32("err", INVALID_OPERATION);
                response->setInt32(
                        "err",
                        mState == UNINITIALIZED ? OK : INVALID_OPERATION);


                response->postReply(replyID);
                response->postReply(replyID);
                break;
                break;