Commit b1fd99ba by olly Committed by Oliver Woodman

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
parent bcd4bf0f
......@@ -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
......
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