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

Commit b3871fad authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Increase the amount of data buffered at preparation time. Make sure to...

Merge "Increase the amount of data buffered at preparation time. Make sure to start preparing after the codecs have been started, otherwise no buffering will happen."
parents 3eda9799 55864df7
Loading
Loading
Loading
Loading
+19 −22
Original line number Diff line number Diff line
@@ -1064,6 +1064,8 @@ void AwesomePlayer::abortPrepare(status_t err) {
}

void AwesomePlayer::onPrepareAsyncEvent() {
    sp<Prefetcher> prefetcher;

    {
        Mutex::Autolock autoLock(mLock);

@@ -1075,21 +1077,6 @@ void AwesomePlayer::onPrepareAsyncEvent() {
                return;
            }
        }
    }

    sp<Prefetcher> prefetcher;

    {
        Mutex::Autolock autoLock(mLock);
        prefetcher = mPrefetcher;
    }

    if (prefetcher != NULL) {
        prefetcher->prepare();
        prefetcher.clear();
    }

    Mutex::Autolock autoLock(mLock);

        if (mVideoTrack != NULL && mVideoSource == NULL) {
            status_t err = initVideoDecoder();
@@ -1109,6 +1096,16 @@ void AwesomePlayer::onPrepareAsyncEvent() {
            }
        }

        prefetcher = mPrefetcher;
    }

    if (prefetcher != NULL) {
        prefetcher->prepare();
        prefetcher.clear();
    }

    Mutex::Autolock autoLock(mLock);

    if (mIsAsyncPrepare) {
        if (mVideoWidth < 0 || mVideoHeight < 0) {
            notifyListener_l(MEDIA_SET_VIDEO_SIZE, 0, 0);
+2 −2
Original line number Diff line number Diff line
@@ -220,13 +220,13 @@ int64_t Prefetcher::getCachedDurationUs(bool *noMoreData) {
}

status_t Prefetcher::prepare() {
    // Buffer about 2 secs worth of data on prepare.
    // Fill the cache.

    int64_t duration;
    bool noMoreData;
    do {
        duration = getCachedDurationUs(&noMoreData);
    } while (!noMoreData && duration < 2000000);
    } while (!noMoreData && duration < kMaxCacheDurationUs);

    return OK;
}