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

Commit 392ec7ae authored by Wonsik Kim's avatar Wonsik Kim Committed by Automerger Merge Worker
Browse files

Merge "stagefright: fix stop-error-error crash" am: 20438f85 am: 9bb55985

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1622989

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib341a6117e19268b89aef1bd02451aac050428b8
parents e011d2ea 9bb55985
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2280,6 +2280,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                                }
                                postPendingRepliesAndDeferredMessages(origin + ":dead");
                                sendErrorResponse = false;
                            } else if (!mReplyID) {
                                sendErrorResponse = false;
                            }
                            break;
                        }
+9 −3
Original line number Diff line number Diff line
@@ -285,10 +285,11 @@ TEST(MediaCodecTest, ErrorWhileStopping) {
    // 1) Client thread calls stop(); MediaCodec looper thread calls
    //    initiateShutdown(); shutdown is being handled at the component thread.
    // 2) Error occurred, but the shutdown operation is still being done.
    // 3) MediaCodec looper thread handles the error.
    // 4) Client releases the codec upon the error; previous shutdown is still
    // 3) Another error occurred during the shutdown operation.
    // 4) MediaCodec looper thread handles the error.
    // 5) Client releases the codec upon the error; previous shutdown is still
    //    going on.
    // 5) Component thread completes shutdown and posts onStopCompleted();
    // 6) Component thread completes shutdown and posts onStopCompleted();
    //    Shutdown from release also completes.

    static const AString kCodecName{"test.codec"};
@@ -317,6 +318,9 @@ TEST(MediaCodecTest, ErrorWhileStopping) {
                });
            ON_CALL(*mockCodec, initiateShutdown(true))
                .WillByDefault([mockCodec](bool) {
                    // 2)
                    mockCodec->callback()->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
                    // 3)
                    mockCodec->callback()->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
                });
            ON_CALL(*mockCodec, initiateShutdown(false))
@@ -339,6 +343,8 @@ TEST(MediaCodecTest, ErrorWhileStopping) {
    codec->start();
    // stop() will fail because of the error
    EXPECT_NE(OK, codec->stop());
    // sleep here so that the looper thread can handle all the errors.
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    // upon receiving the error, client tries to release the codec.
    codec->release();
    looper->stop();