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

Commit bf4c0c88 authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am cec075cc: am 23584022: Merge "Ensure that buffering updates eventually hit...

am cec075cc: am 23584022: Merge "Ensure that buffering updates eventually hit 100% after we download everything." into gingerbread

Merge commit 'cec075cc'

* commit 'cec075cc':
  Ensure that buffering updates eventually hit 100% after we download everything.
parents dc9e486e cec075cc
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -461,9 +461,15 @@ void AwesomePlayer::onBufferingUpdate() {
        return;
    }

    bool eos;
    size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&eos);

    size_t lowWatermark = 400000;
    size_t highWatermark = 1000000;

    if (eos) {
        notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
    } else {
        off_t size;
        if (mDurationUs >= 0 && mCachedSource->getSize(&size) == OK) {
            int64_t bitrate = size * 8000000ll / mDurationUs;  // in bits/sec
@@ -471,16 +477,17 @@ void AwesomePlayer::onBufferingUpdate() {
            size_t cachedSize = mCachedSource->cachedSize();
            int64_t cachedDurationUs = cachedSize * 8000000ll / bitrate;

        double percentage = (double)cachedDurationUs / mDurationUs;
            int percentage = 100.0 * (double)cachedDurationUs / mDurationUs;
            if (percentage > 100) {
                percentage = 100;
            }

        notifyListener_l(MEDIA_BUFFERING_UPDATE, percentage * 100.0);
            notifyListener_l(MEDIA_BUFFERING_UPDATE, percentage);

            lowWatermark = 2 * bitrate / 8;  // 2 secs
            highWatermark = 10 * bitrate / 8;  // 10 secs
        }

    bool eos;
    size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&eos);
    }

    if ((mFlags & PLAYING) && !eos && (cachedDataRemaining < lowWatermark)) {
        LOGI("cache is running low (< %d) , pausing.", lowWatermark);