summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/AwesomePlayer.cpp
diff options
context:
space:
mode:
authorRobert Shih <robertshih@google.com>2014-04-17 11:16:05 -0700
committerRobert Shih <robertshih@google.com>2014-04-25 14:14:39 -0700
commit15387a6e8e7930ea80f46c98fab54f22981e7f11 (patch)
tree1868b13c6841f7b3433445f597b13a3990e68c95 /media/libstagefright/AwesomePlayer.cpp
parent67ee990d324229ab0565ce632bd5a04297e16a01 (diff)
downloadframeworks_av-15387a6e8e7930ea80f46c98fab54f22981e7f11.zip
frameworks_av-15387a6e8e7930ea80f46c98fab54f22981e7f11.tar.gz
frameworks_av-15387a6e8e7930ea80f46c98fab54f22981e7f11.tar.bz2
AwesomePlayer: fixed division by zero in onBufferingUpdate
Bug: 13911283 Change-Id: I968a274634a86f5c46f75dc533024dad44afc36b
Diffstat (limited to 'media/libstagefright/AwesomePlayer.cpp')
-rw-r--r--media/libstagefright/AwesomePlayer.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index e924076..6e5003f 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -718,11 +718,9 @@ void AwesomePlayer::onBufferingUpdate() {
finishAsyncPrepare_l();
}
} else {
- int64_t bitrate;
- if (getBitrate(&bitrate)) {
- size_t cachedSize = mCachedSource->cachedSize();
- int64_t cachedDurationUs = cachedSize * 8000000ll / bitrate;
-
+ bool eos2;
+ int64_t cachedDurationUs;
+ if (getCachedDuration_l(&cachedDurationUs, &eos2) && mDurationUs > 0) {
int percentage = 100.0 * (double)cachedDurationUs / mDurationUs;
if (percentage > 100) {
percentage = 100;
@@ -730,7 +728,7 @@ void AwesomePlayer::onBufferingUpdate() {
notifyListener_l(MEDIA_BUFFERING_UPDATE, percentage);
} else {
- // We don't know the bitrate of the stream, use absolute size
+ // We don't know the bitrate/duration of the stream, use absolute size
// limits to maintain the cache.
if ((mFlags & PLAYING) && !eos