Commit 2ce17b60 by Oliver Woodman

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.
parent d2da3bbf
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment