Make OggSeeker.startSeek take a granule rather than a time

PiperOrigin-RevId: 261102180
This commit is contained in:
olly 2019-08-01 13:06:45 +01:00 committed by Oliver Woodman
parent cbc1385fd3
commit 95ed5ce65d
4 changed files with 13 additions and 17 deletions

View File

@ -120,12 +120,11 @@ import java.io.IOException;
}
@Override
public long startSeek(long timeUs) {
public void startSeek(long targetGranule) {
Assertions.checkArgument(state == STATE_IDLE || state == STATE_SEEK);
targetGranule = timeUs == 0 ? 0 : streamReader.convertTimeToGranule(timeUs);
this.targetGranule = targetGranule;
state = STATE_SEEK;
resetSeeking();
return targetGranule;
}
@Override

View File

@ -185,11 +185,9 @@ import java.util.List;
}
@Override
public long startSeek(long timeUs) {
long granule = convertTimeToGranule(timeUs);
int index = Util.binarySearchFloor(seekPointGranules, granule, true, true);
public void startSeek(long targetGranule) {
int index = Util.binarySearchFloor(seekPointGranules, targetGranule, true, true);
pendingSeekGranule = seekPointGranules[index];
return granule;
}
@Override

View File

@ -33,16 +33,14 @@ import java.io.IOException;
SeekMap createSeekMap();
/**
* Initializes a seek operation.
* Starts a seek operation.
*
* @param timeUs The seek position in microseconds.
* @return The granule position targeted by the seek.
* @param targetGranule The target granule position.
*/
long startSeek(long timeUs);
void startSeek(long targetGranule);
/**
* Reads data from the {@link ExtractorInput} to build the {@link SeekMap} or to continue a
* progressive seek.
* Reads data from the {@link ExtractorInput} to build the {@link SeekMap} or to continue a seek.
* <p/>
* If more data is required or if the position of the input needs to be modified then a position
* from which data should be provided is returned. Else a negative value is returned. If a seek

View File

@ -91,7 +91,8 @@ import java.io.IOException;
reset(!seekMapSet);
} else {
if (state != STATE_READ_HEADERS) {
targetGranule = oggSeeker.startSeek(timeUs);
targetGranule = convertTimeToGranule(timeUs);
oggSeeker.startSeek(targetGranule);
state = STATE_READ_PAYLOAD;
}
}
@ -248,13 +249,13 @@ import java.io.IOException;
private static final class UnseekableOggSeeker implements OggSeeker {
@Override
public long read(ExtractorInput input) throws IOException, InterruptedException {
public long read(ExtractorInput input) {
return -1;
}
@Override
public long startSeek(long timeUs) {
return 0;
public void startSeek(long targetGranule) {
// Do nothing.
}
@Override