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

Commit 80bc81ba authored by Wonsik Kim's avatar Wonsik Kim
Browse files

stagefright: notify async release complete

Bug: 158158088
Test: atest CtsMediaTestCases:MediaCodecCapabilitiesTest#testGetMaxSupportedInstances
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Change-Id: I6fe5547cfef0c03e8d929569a3b28fae197ae99b
parent fa9ced08
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -1474,9 +1474,9 @@ status_t MediaCodec::release() {
    return PostAndAwaitResponse(msg, &response);
}

status_t MediaCodec::releaseAsync() {
status_t MediaCodec::releaseAsync(const sp<AMessage> &notify) {
    sp<AMessage> msg = new AMessage(kWhatRelease, this);
    msg->setInt32("async", 1);
    msg->setMessage("async", notify);
    sp<AMessage> response;
    return PostAndAwaitResponse(msg, &response);
}
@@ -2648,6 +2648,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                    if (mReplyID != nullptr) {
                        (new AMessage)->postReply(mReplyID);
                    }
                    if (mAsyncReleaseCompleteNotification != nullptr) {
                        flushMediametrics();
                        mAsyncReleaseCompleteNotification->post();
                        mAsyncReleaseCompleteNotification.clear();
                    }
                    break;
                }

@@ -3034,8 +3039,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                break;
            }

            int32_t async = 0;
            if (msg->findInt32("async", &async) && async) {
            sp<AMessage> asyncNotify;
            if (msg->findMessage("async", &asyncNotify) && asyncNotify != nullptr) {
                if (mSurface != NULL) {
                    if (!mReleaseSurface) {
                        mReleaseSurface.reset(new ReleaseSurface);
@@ -3067,10 +3072,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                pushBlankBuffersToNativeWindow(mSurface.get());
            }

            if (async) {
            if (asyncNotify != nullptr) {
                mResourceManagerProxy->markClientForPendingRemoval();
                (new AMessage)->postReply(mReplyID);
                mReplyID = 0;
                mAsyncReleaseCompleteNotification = asyncNotify;
            }

            break;
+2 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ struct MediaCodec : public AHandler {
    // object.
    status_t release();

    status_t releaseAsync();
    status_t releaseAsync(const sp<AMessage> &notify);

    status_t flush();

@@ -382,6 +382,7 @@ private:
    sp<AMessage> mInputFormat;
    sp<AMessage> mCallback;
    sp<AMessage> mOnFrameRenderedNotification;
    sp<AMessage> mAsyncReleaseCompleteNotification;

    sp<ResourceManagerServiceProxy> mResourceManagerProxy;