From b9b8d14d89019ba7b9d183f0fbad2af924a0cd95 Mon Sep 17 00:00:00 2001 From: hovanchen Date: Tue, 2 Jul 2013 15:07:44 +0800 Subject: Prevent Media Server crash while the AwesomePlayer getBitrate return true with mBitrate equals to zero. [Cause] - getBitrate(int64_t *bitrate) will return true if mBitrate = 0. - Then, in getCachedDuration_l(int64_t *durationUs, bool *eos), we might execute the following function when getBitrate(&bitrate) = true and bitrate = 0. *durationUs = cachedDataRemaining * 8000000ll / bitrate; - Mediaserver will be crashed when divided by zero. - The mediaserver crash often occur when DLNA IOP tests on Golden DMS with AAC_ADTS_320 audio. [Solution] - Prevent the divide function executing when bitrate is zero. Change-Id: I4439d92cee5faec95df2109e9186c33b3fff6c66 --- media/libstagefright/AwesomePlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 1e2625a..70e6690 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -617,7 +617,7 @@ bool AwesomePlayer::getBitrate(int64_t *bitrate) { bool AwesomePlayer::getCachedDuration_l(int64_t *durationUs, bool *eos) { int64_t bitrate; - if (mCachedSource != NULL && getBitrate(&bitrate)) { + if (mCachedSource != NULL && getBitrate(&bitrate) && (bitrate > 0)) { status_t finalStatus; size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&finalStatus); *durationUs = cachedDataRemaining * 8000000ll / bitrate; -- cgit v1.1