HTTPLiveSource: check for NULL before getTrackCount/Info
The effect is MediaPlayer returns a 0-length array when getTrackInfo is
called before PREPARED state.
Bug: 12029173
Change-Id: Ib3a48525eac07b04a2ff88ce199d66dcc61c1641
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 8667a6b..7b18348 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -1019,11 +1019,19 @@
}
size_t LiveSession::getTrackCount() const {
- return mPlaylist->getTrackCount();
+ if (mPlaylist == NULL) {
+ return 0;
+ } else {
+ return mPlaylist->getTrackCount();
+ }
}
sp<AMessage> LiveSession::getTrackInfo(size_t trackIndex) const {
- return mPlaylist->getTrackInfo(trackIndex);
+ if (mPlaylist == NULL) {
+ return NULL;
+ } else {
+ return mPlaylist->getTrackInfo(trackIndex);
+ }
}
status_t LiveSession::selectTrack(size_t index, bool select) {