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

Merge commit '235840228b0692b66d854ff499b5c4060f883e03' into gingerbread-plus-aosp

* commit '235840228b0692b66d854ff499b5c4060f883e03':
  Ensure that buffering updates eventually hit 100% after we download everything.
This commit is contained in:
Andreas Huber
2010-08-25 15:01:45 -07:00
committed by Android Git Automerger

View File

@@ -458,27 +458,34 @@ void AwesomePlayer::onBufferingUpdate() {
return;
}
bool eos;
size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&eos);
size_t lowWatermark = 400000;
size_t highWatermark = 1000000;
off_t size;
if (mDurationUs >= 0 && mCachedSource->getSize(&size) == OK) {
int64_t bitrate = size * 8000000ll / mDurationUs; // in bits/sec
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
size_t cachedSize = mCachedSource->cachedSize();
int64_t cachedDurationUs = cachedSize * 8000000ll / bitrate;
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
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);
mFlags |= CACHE_UNDERRUN;