mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
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.
This commit is contained in:
parent
d2da3bbf8a
commit
2ce17b601f
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user