From 2ce17b601fa5b46f9c9d63a93d123676a06ea853 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Wed, 25 Feb 2015 13:34:31 +0000 Subject: [PATCH] Correctly bound search into segment indices. The return value here assumed that the time being searched for was beyond the start time of the last segment. This fix also handles the case where the time is prior to the start of the first segment. --- .../com/google/android/exoplayer/dash/mpd/SegmentBase.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java index f93ce33743..c6eec00602 100644 --- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java +++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java @@ -148,7 +148,8 @@ public abstract class SegmentBase { * @see DashSegmentIndex#getSegmentNum(long) */ public int getSegmentNum(long timeUs) { - int lowIndex = getFirstSegmentNum(); + final int firstSegmentNum = getFirstSegmentNum(); + int lowIndex = firstSegmentNum; int highIndex = getLastSegmentNum(); if (segmentTimeline == null) { // All segments are of equal duration (with the possible exception of the last one). @@ -171,7 +172,7 @@ public abstract class SegmentBase { return midIndex; } } - return lowIndex - 1; + return lowIndex == firstSegmentNum ? lowIndex : highIndex; } }