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

Commit 5596d7c4 authored by Wei Jia's avatar Wei Jia Committed by Android (Google) Code Review
Browse files

Merge "Allow audio and video flushed separately." into lmp-dev

parents 65736932 53904f37
Loading
Loading
Loading
Loading
+14 −54
Original line number Original line Diff line number Diff line
@@ -964,11 +964,13 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
}
}


void NuPlayer::finishFlushIfPossible() {
void NuPlayer::finishFlushIfPossible() {
    if (mFlushingAudio != FLUSHED && mFlushingAudio != SHUT_DOWN) {
    if (mFlushingAudio != NONE && mFlushingAudio != FLUSHED
            && mFlushingAudio != SHUT_DOWN) {
        return;
        return;
    }
    }


    if (mFlushingVideo != FLUSHED && mFlushingVideo != SHUT_DOWN) {
    if (mFlushingVideo != NONE && mFlushingVideo != FLUSHED
            && mFlushingVideo != SHUT_DOWN) {
        return;
        return;
    }
    }


@@ -979,11 +981,11 @@ void NuPlayer::finishFlushIfPossible() {
        mTimeDiscontinuityPending = false;
        mTimeDiscontinuityPending = false;
    }
    }


    if (mAudioDecoder != NULL) {
    if (mAudioDecoder != NULL && mFlushingAudio == FLUSHED) {
        mAudioDecoder->signalResume();
        mAudioDecoder->signalResume();
    }
    }


    if (mVideoDecoder != NULL) {
    if (mVideoDecoder != NULL && mFlushingVideo == FLUSHED) {
        mVideoDecoder->signalResume();
        mVideoDecoder->signalResume();
    }
    }


@@ -1221,8 +1223,8 @@ status_t NuPlayer::feedDecoderInputData(bool audio, const sp<AMessage> &msg) {
    sp<AMessage> reply;
    sp<AMessage> reply;
    CHECK(msg->findMessage("reply", &reply));
    CHECK(msg->findMessage("reply", &reply));


    if ((audio && IsFlushingState(mFlushingAudio))
    if ((audio && mFlushingAudio != NONE)
            || (!audio && IsFlushingState(mFlushingVideo))) {
            || (!audio && mFlushingVideo != NONE)) {
        reply->setInt32("err", INFO_DISCONTINUITY);
        reply->setInt32("err", INFO_DISCONTINUITY);
        reply->post();
        reply->post();
        return OK;
        return OK;
@@ -1302,15 +1304,6 @@ status_t NuPlayer::feedDecoderInputData(bool audio, const sp<AMessage> &msg) {
                    }
                    }
                } else {
                } else {
                    // This stream is unaffected by the discontinuity
                    // This stream is unaffected by the discontinuity

                    if (audio) {
                        mFlushingAudio = FLUSHED;
                    } else {
                        mFlushingVideo = FLUSHED;
                    }

                    finishFlushIfPossible();

                    return -EWOULDBLOCK;
                    return -EWOULDBLOCK;
                }
                }
            }
            }
@@ -1361,7 +1354,8 @@ void NuPlayer::renderBuffer(bool audio, const sp<AMessage> &msg) {
    sp<AMessage> reply;
    sp<AMessage> reply;
    CHECK(msg->findMessage("reply", &reply));
    CHECK(msg->findMessage("reply", &reply));


    if (IsFlushingState(audio ? mFlushingAudio : mFlushingVideo)) {
    if ((audio && mFlushingAudio != NONE)
            || (!audio && mFlushingVideo != NONE)) {
        // We're currently attempting to flush the decoder, in order
        // We're currently attempting to flush the decoder, in order
        // to complete this, the decoder wants all its buffers back,
        // to complete this, the decoder wants all its buffers back,
        // so we don't want any output buffers it sent us (from before
        // so we don't want any output buffers it sent us (from before
@@ -1506,27 +1500,13 @@ void NuPlayer::flushDecoder(bool audio, bool needShutdown) {
        needShutdown ? FLUSHING_DECODER_SHUTDOWN : FLUSHING_DECODER;
        needShutdown ? FLUSHING_DECODER_SHUTDOWN : FLUSHING_DECODER;


    if (audio) {
    if (audio) {
        CHECK(mFlushingAudio == NONE
        ALOGE_IF(mFlushingAudio != NONE,
                || mFlushingAudio == AWAITING_DISCONTINUITY);
                "audio flushDecoder() is called in state %d", mFlushingAudio);

        mFlushingAudio = newStatus;
        mFlushingAudio = newStatus;

        if (mFlushingVideo == NONE) {
            mFlushingVideo = (mVideoDecoder != NULL)
                ? AWAITING_DISCONTINUITY
                : FLUSHED;
        }
    } else {
    } else {
        CHECK(mFlushingVideo == NONE
        ALOGE_IF(mFlushingVideo != NONE,
                || mFlushingVideo == AWAITING_DISCONTINUITY);
                "video flushDecoder() is called in state %d", mFlushingVideo);

        mFlushingVideo = newStatus;
        mFlushingVideo = newStatus;

        if (mFlushingAudio == NONE) {
            mFlushingAudio = (mAudioDecoder != NULL)
                ? AWAITING_DISCONTINUITY
                : FLUSHED;
        }
    }
    }
}
}


@@ -1616,18 +1596,6 @@ void NuPlayer::processDeferredActions() {
        // an intermediate state, i.e. one more more decoders are currently
        // an intermediate state, i.e. one more more decoders are currently
        // flushing or shutting down.
        // flushing or shutting down.


        if (mRenderer != NULL) {
            // There's an edge case where the renderer owns all output
            // buffers and is paused, therefore the decoder will not read
            // more input data and will never encounter the matching
            // discontinuity. To avoid this, we resume the renderer.

            if (mFlushingAudio == AWAITING_DISCONTINUITY
                    || mFlushingVideo == AWAITING_DISCONTINUITY) {
                mRenderer->resume();
            }
        }

        if (mFlushingAudio != NONE || mFlushingVideo != NONE) {
        if (mFlushingAudio != NONE || mFlushingVideo != NONE) {
            // We're currently flushing, postpone the reset until that's
            // We're currently flushing, postpone the reset until that's
            // completed.
            // completed.
@@ -1692,14 +1660,6 @@ void NuPlayer::performDecoderShutdown(bool audio, bool video) {


    mTimeDiscontinuityPending = true;
    mTimeDiscontinuityPending = true;


    if (mFlushingAudio == NONE && (!audio || mAudioDecoder == NULL)) {
        mFlushingAudio = FLUSHED;
    }

    if (mFlushingVideo == NONE && (!video || mVideoDecoder == NULL)) {
        mFlushingVideo = FLUSHED;
    }

    if (audio && mAudioDecoder != NULL) {
    if (audio && mAudioDecoder != NULL) {
        flushDecoder(true /* audio */, true /* needShutdown */);
        flushDecoder(true /* audio */, true /* needShutdown */);
    }
    }
+0 −1
Original line number Original line Diff line number Diff line
@@ -145,7 +145,6 @@ private:


    enum FlushStatus {
    enum FlushStatus {
        NONE,
        NONE,
        AWAITING_DISCONTINUITY,
        FLUSHING_DECODER,
        FLUSHING_DECODER,
        FLUSHING_DECODER_SHUTDOWN,
        FLUSHING_DECODER_SHUTDOWN,
        SHUTTING_DOWN_DECODER,
        SHUTTING_DOWN_DECODER,