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

Commit d45203ca authored by Chong Zhang's avatar Chong Zhang Committed by Android Git Automerger
Browse files

am 1bc88814: Merge "NuPlayer: pull more video buffers in advance in GenericSource" into mnc-dev

* commit '1bc88814':
  NuPlayer: pull more video buffers in advance in GenericSource
parents 4d9b301e 1bc88814
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -1005,7 +1005,9 @@ status_t NuPlayer::GenericSource::dequeueAccessUnit(


    status_t result = track->mPackets->dequeueAccessUnit(accessUnit);
    status_t result = track->mPackets->dequeueAccessUnit(accessUnit);


    if (!track->mPackets->hasBufferAvailable(&finalResult)) {
    // start pulling in more buffers if we only have one (or no) buffer left
    // so that decoder has less chance of being starved
    if (track->mPackets->getAvailableBufferCount(&finalResult) < 2) {
        postReadBuffer(audio? MEDIA_TRACK_TYPE_AUDIO : MEDIA_TRACK_TYPE_VIDEO);
        postReadBuffer(audio? MEDIA_TRACK_TYPE_AUDIO : MEDIA_TRACK_TYPE_VIDEO);
    }
    }


@@ -1458,6 +1460,8 @@ void NuPlayer::GenericSource::readBuffer(
            track = &mVideoTrack;
            track = &mVideoTrack;
            if (mIsWidevine) {
            if (mIsWidevine) {
                maxBuffers = 2;
                maxBuffers = 2;
            } else {
                maxBuffers = 4;
            }
            }
            break;
            break;
        case MEDIA_TRACK_TYPE_AUDIO:
        case MEDIA_TRACK_TYPE_AUDIO:
+14 −0
Original line number Original line Diff line number Diff line
@@ -394,6 +394,20 @@ bool AnotherPacketSource::hasDataBufferAvailable(status_t *finalResult) {
    return false;
    return false;
}
}


size_t AnotherPacketSource::getAvailableBufferCount(status_t *finalResult) {
    Mutex::Autolock autoLock(mLock);

    *finalResult = OK;
    if (!mEnabled) {
        return 0;
    }
    if (!mBuffers.empty()) {
        return mBuffers.size();
    }
    *finalResult = mEOSResult;
    return 0;
}

int64_t AnotherPacketSource::getBufferedDurationUs(status_t *finalResult) {
int64_t AnotherPacketSource::getBufferedDurationUs(status_t *finalResult) {
    Mutex::Autolock autoLock(mLock);
    Mutex::Autolock autoLock(mLock);
    *finalResult = mEOSResult;
    *finalResult = mEOSResult;
+4 −0
Original line number Original line Diff line number Diff line
@@ -49,6 +49,10 @@ struct AnotherPacketSource : public MediaSource {
    // Returns true if we have packets that's not discontinuities
    // Returns true if we have packets that's not discontinuities
    bool hasDataBufferAvailable(status_t *finalResult);
    bool hasDataBufferAvailable(status_t *finalResult);


    // Returns the number of available buffers. finalResult is always OK
    // if this method returns non-0, or the final result if it returns 0.
    size_t getAvailableBufferCount(status_t *finalResult);

    // Returns the difference between the last and the first queued
    // Returns the difference between the last and the first queued
    // presentation timestamps since the last discontinuity (if any).
    // presentation timestamps since the last discontinuity (if any).
    int64_t getBufferedDurationUs(status_t *finalResult);
    int64_t getBufferedDurationUs(status_t *finalResult);