OSDN Git Service

Add null check for rtsp source
authorTakahiro Aizawa <takahiro.aizawa@sonymobile.com>
Mon, 20 Jun 2016 00:53:47 +0000 (09:53 +0900)
committerRobert Shih <robertshih@google.com>
Wed, 13 Jul 2016 01:07:49 +0000 (18:07 -0700)
During playback contents with multi audio tracks or multi video tracks,
crash occurs in checkBuffering() which is added from Android-N.
The reason is because instance is not set in mSource in onConnected().
This commit adds null check to prevent crash.

Bug: 29520487

Change-Id: I893c11a7339e938b1f3b79805c2fb3d9be5cfc96
Signed-off-by: ZHU XINGYUE <zhu.x.xingyue@sonymobile.com>
media/libmediaplayerservice/nuplayer/RTSPSource.cpp

index 1b7dff5..8a305de 100644 (file)
@@ -318,10 +318,16 @@ void NuPlayer::RTSPSource::checkBuffering(
     size_t numTracks = mTracks.size();
     size_t preparedCount, underflowCount, overflowCount, startCount;
     preparedCount = underflowCount = overflowCount = startCount = 0;
-    for (size_t i = 0; i < numTracks; ++i) {
+
+    size_t count = numTracks;
+    for (size_t i = 0; i < count; ++i) {
         status_t finalResult;
         TrackInfo *info = &mTracks.editItemAt(i);
         sp<AnotherPacketSource> src = info->mSource;
+        if (src == NULL) {
+            --numTracks;
+            continue;
+        }
         int64_t bufferedDurationUs = src->getBufferedDurationUs(&finalResult);
 
         // isFinished when duration is 0 checks for EOS result only