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

Commit 55864df7 authored by Andreas Huber's avatar Andreas Huber
Browse files

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

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.

Change-Id: I2c54db085cc76f4069ab381177e94e1b81005b02
related-to-bug: 2474091
parent 3c53c69a
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;
}