Make OggSeeker.startSeek take a granule rather than a time
PiperOrigin-RevId: 261102180
This commit is contained in:
parent
cbc1385fd3
commit
95ed5ce65d
@ -120,12 +120,11 @@ import java.io.IOException;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long startSeek(long timeUs) {
|
public void startSeek(long targetGranule) {
|
||||||
Assertions.checkArgument(state == STATE_IDLE || state == STATE_SEEK);
|
Assertions.checkArgument(state == STATE_IDLE || state == STATE_SEEK);
|
||||||
targetGranule = timeUs == 0 ? 0 : streamReader.convertTimeToGranule(timeUs);
|
this.targetGranule = targetGranule;
|
||||||
state = STATE_SEEK;
|
state = STATE_SEEK;
|
||||||
resetSeeking();
|
resetSeeking();
|
||||||
return targetGranule;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -185,11 +185,9 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long startSeek(long timeUs) {
|
public void startSeek(long targetGranule) {
|
||||||
long granule = convertTimeToGranule(timeUs);
|
int index = Util.binarySearchFloor(seekPointGranules, targetGranule, true, true);
|
||||||
int index = Util.binarySearchFloor(seekPointGranules, granule, true, true);
|
|
||||||
pendingSeekGranule = seekPointGranules[index];
|
pendingSeekGranule = seekPointGranules[index];
|
||||||
return granule;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,16 +33,14 @@ import java.io.IOException;
|
|||||||
SeekMap createSeekMap();
|
SeekMap createSeekMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a seek operation.
|
* Starts a seek operation.
|
||||||
*
|
*
|
||||||
* @param timeUs The seek position in microseconds.
|
* @param targetGranule The target granule position.
|
||||||
* @return The granule position targeted by the seek.
|
|
||||||
*/
|
*/
|
||||||
long startSeek(long timeUs);
|
void startSeek(long targetGranule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads data from the {@link ExtractorInput} to build the {@link SeekMap} or to continue a
|
* Reads data from the {@link ExtractorInput} to build the {@link SeekMap} or to continue a seek.
|
||||||
* progressive seek.
|
|
||||||
* <p/>
|
* <p/>
|
||||||
* If more data is required or if the position of the input needs to be modified then a position
|
* 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
|
* from which data should be provided is returned. Else a negative value is returned. If a seek
|
||||||
|
@ -91,7 +91,8 @@ import java.io.IOException;
|
|||||||
reset(!seekMapSet);
|
reset(!seekMapSet);
|
||||||
} else {
|
} else {
|
||||||
if (state != STATE_READ_HEADERS) {
|
if (state != STATE_READ_HEADERS) {
|
||||||
targetGranule = oggSeeker.startSeek(timeUs);
|
targetGranule = convertTimeToGranule(timeUs);
|
||||||
|
oggSeeker.startSeek(targetGranule);
|
||||||
state = STATE_READ_PAYLOAD;
|
state = STATE_READ_PAYLOAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,13 +249,13 @@ import java.io.IOException;
|
|||||||
private static final class UnseekableOggSeeker implements OggSeeker {
|
private static final class UnseekableOggSeeker implements OggSeeker {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long read(ExtractorInput input) throws IOException, InterruptedException {
|
public long read(ExtractorInput input) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long startSeek(long timeUs) {
|
public void startSeek(long targetGranule) {
|
||||||
return 0;
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user