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

Commit 00e1af96 authored by Wonsik Kim's avatar Wonsik Kim
Browse files

MediaCodec: don't crash on concurrent release/allocate

Bug: 128357480
Test: atest CtsMediaTestCases:MediaCodecTest#testAsyncRelease
Change-Id: I814f50c43225a06c87d51d6eb57ab1957dcd517a
parent 0e5a1b3b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1934,6 +1934,13 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {

                case kWhatComponentAllocated:
                {
                    if (mState == RELEASING || mState == UNINITIALIZED) {
                        // In case a kWhatError or kWhatRelease message came in and replied,
                        // we log a warning and ignore.
                        ALOGW("allocate interrupted by error or release, current state %d",
                              mState);
                        break;
                    }
                    CHECK_EQ(mState, INITIALIZING);
                    setState(INITIALIZED);
                    mFlags |= kFlagIsComponentAllocated;