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:
@@ -458,27 +458,34 @@ void AwesomePlayer::onBufferingUpdate() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool eos;
|
||||||
|
size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&eos);
|
||||||
|
|
||||||
size_t lowWatermark = 400000;
|
size_t lowWatermark = 400000;
|
||||||
size_t highWatermark = 1000000;
|
size_t highWatermark = 1000000;
|
||||||
|
|
||||||
off_t size;
|
if (eos) {
|
||||||
if (mDurationUs >= 0 && mCachedSource->getSize(&size) == OK) {
|
notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
|
||||||
int64_t bitrate = size * 8000000ll / mDurationUs; // in bits/sec
|
} 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();
|
size_t cachedSize = mCachedSource->cachedSize();
|
||||||
int64_t cachedDurationUs = cachedSize * 8000000ll / bitrate;
|
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
|
lowWatermark = 2 * bitrate / 8; // 2 secs
|
||||||
highWatermark = 10 * bitrate / 8; // 10 secs
|
highWatermark = 10 * bitrate / 8; // 10 secs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool eos;
|
|
||||||
size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&eos);
|
|
||||||
|
|
||||||
if ((mFlags & PLAYING) && !eos && (cachedDataRemaining < lowWatermark)) {
|
if ((mFlags & PLAYING) && !eos && (cachedDataRemaining < lowWatermark)) {
|
||||||
LOGI("cache is running low (< %d) , pausing.", lowWatermark);
|
LOGI("cache is running low (< %d) , pausing.", lowWatermark);
|
||||||
mFlags |= CACHE_UNDERRUN;
|
mFlags |= CACHE_UNDERRUN;
|
||||||
|
|||||||
Reference in New Issue
Block a user