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 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.mp3; package com.google.android.exoplayer2.extractor.mp3;
import com.google.android.exoplayer2.C; 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. * 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; ...@@ -41,8 +42,11 @@ import com.google.android.exoplayer2.C;
@Override @Override
public long getPosition(long timeUs) { public long getPosition(long timeUs) {
return durationUs == C.TIME_UNSET ? 0 if (durationUs == C.TIME_UNSET) {
: firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE); return 0;
}
timeUs = Util.constrainValue(timeUs, 0, durationUs);
return firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE);
} }
@Override @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