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

Commit 3d66eb41 authored by Chong Zhang's avatar Chong Zhang
Browse files

MediaCodec: hold input buffers during FLUSHED state

bug: 20267388
Change-Id: I21a12cb2ebb74e17dcdb7b502c3f674e9e64b5dc
parent 71933d76
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -304,6 +304,7 @@ private:
    sp<AMessage> mActivityNotify;

    bool mHaveInputSurface;
    bool mHavePendingInputBuffers;

    MediaCodec(const sp<ALooper> &looper);

+11 −2
Original line number Diff line number Diff line
@@ -320,7 +320,8 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper)
      mDequeueInputReplyID(0),
      mDequeueOutputTimeoutGeneration(0),
      mDequeueOutputReplyID(0),
      mHaveInputSurface(false) {
      mHaveInputSurface(false),
      mHavePendingInputBuffers(false) {
}

MediaCodec::~MediaCodec() {
@@ -1380,8 +1381,12 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {

                    if (mFlags & kFlagIsAsync) {
                        if (!mHaveInputSurface) {
                            if (mState == FLUSHED) {
                                mHavePendingInputBuffers = true;
                            } else {
                                onInputBufferAvailable();
                            }
                        }
                    } else if (mFlags & kFlagDequeueInputPending) {
                        CHECK(handleDequeueInputBuffer(mDequeueInputReplyID));

@@ -1648,6 +1653,10 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {

            if (mState == FLUSHED) {
                setState(STARTED);
                if (mHavePendingInputBuffers) {
                    onInputBufferAvailable();
                    mHavePendingInputBuffers = false;
                }
                mCodec->signalResume();
                PostReplyWithError(replyID, OK);
                break;