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

Commit dfe5c421 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "NuPlayer: queue a deferred scan sources when flushing during scan"

parents f65f03bc 3b032b38
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1417,7 +1417,11 @@ void NuPlayer::flushDecoder(bool audio, bool needShutdown) {

    // Make sure we don't continue to scan sources until we finish flushing.
    ++mScanSourcesGeneration;
    if (mScanSourcesPending) {
        mDeferredActions.push_back(
                new SimpleAction(&NuPlayer::performScanSources));
        mScanSourcesPending = false;
    }

    decoder->signalFlush();

+13 −13
Original line number Diff line number Diff line
@@ -82,14 +82,16 @@ void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatCodecNotify:
        {
            int32_t cbID;
            CHECK(msg->findInt32("callbackID", &cbID));

            ALOGV("[%s] kWhatCodecNotify: cbID = %d, paused = %d",
                    mIsAudio ? "audio" : "video", cbID, mPaused);

            if (mPaused) {
                break;
            }

            int32_t cbID;
            CHECK(msg->findInt32("callbackID", &cbID));

            ALOGV("kWhatCodecNotify: cbID = %d", cbID);
            switch (cbID) {
                case MediaCodec::CB_INPUT_AVAILABLE:
                {
@@ -356,11 +358,14 @@ void NuPlayer::Decoder::onShutdown(bool notifyComplete) {
    }
}

void NuPlayer::Decoder::doRequestBuffers() {
/*
 * returns true if we should request more data
 */
bool NuPlayer::Decoder::doRequestBuffers() {
    // mRenderer is only NULL if we have a legacy widevine source that
    // is not yet ready. In this case we must not fetch input.
    if (isDiscontinuityPending() || mRenderer == NULL) {
        return;
        return false;
    }
    status_t err = OK;
    while (err == OK && !mDequeuedInputBuffers.empty()) {
@@ -380,10 +385,8 @@ void NuPlayer::Decoder::doRequestBuffers() {
        }
    }

    if (err == -EWOULDBLOCK
            && mSource->feedMoreTSData() == OK) {
        scheduleRequestBuffers();
    }
    return err == -EWOULDBLOCK
            && mSource->feedMoreTSData() == OK;
}

void NuPlayer::Decoder::handleError(int32_t err)
@@ -846,9 +849,6 @@ void NuPlayer::Decoder::finishHandleDiscontinuity(bool flushOnTimeChange) {
            doFlush(false /* notifyComplete */);
            signalResume(false /* notifyComplete */);
        }

        // restart fetching input
        scheduleRequestBuffers();
    }

    // Notify NuPlayer to either shutdown decoder, or rescan sources
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ protected:
    virtual void onResume(bool notifyComplete);
    virtual void onFlush();
    virtual void onShutdown(bool notifyComplete);
    virtual void doRequestBuffers();
    virtual bool doRequestBuffers();

private:
    enum {
+5 −8
Original line number Diff line number Diff line
@@ -103,17 +103,14 @@ void NuPlayer::DecoderBase::onRequestInputBuffers() {
        return;
    }

    doRequestBuffers();
}

void NuPlayer::DecoderBase::scheduleRequestBuffers() {
    if (mRequestInputBuffersPending) {
        return;
    }
    // doRequestBuffers() return true if we should request more data
    if (doRequestBuffers()) {
        mRequestInputBuffersPending = true;

        sp<AMessage> msg = new AMessage(kWhatRequestInputBuffers, this);
        msg->post(10 * 1000ll);
    }
}

void NuPlayer::DecoderBase::onMessageReceived(const sp<AMessage> &msg) {

+1 −2
Original line number Diff line number Diff line
@@ -69,8 +69,7 @@ protected:
    virtual void onShutdown(bool notifyComplete) = 0;

    void onRequestInputBuffers();
    void scheduleRequestBuffers();
    virtual void doRequestBuffers() = 0;
    virtual bool doRequestBuffers() = 0;
    virtual void handleError(int32_t err);

    sp<AMessage> mNotify;
Loading