Constraint seeks within bounds for ConstantBitrateSeeker

We do this everywhere for index based seeking already.

Issue: #2876

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157568788
This commit is contained in:
olly 2017-05-31 03:16:47 -07:00 committed by Oliver Woodman
parent 854c8d0381
commit c80b60f4ac

View File

@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.mp3;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util;
/**
* MP3 seeker that doesn't rely on metadata and seeks assuming the source has a constant bitrate.
@ -41,8 +42,11 @@ import com.google.android.exoplayer2.C;
@Override
public long getPosition(long timeUs) {
return durationUs == C.TIME_UNSET ? 0
: firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE);
if (durationUs == C.TIME_UNSET) {
return 0;
}
timeUs = Util.constrainValue(timeUs, 0, durationUs);
return firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE);
}
@Override