mirror of
https://github.com/androidx/media.git
synced 2025-05-17 12:39:52 +08:00
Move resetting the peek position to ExtractorSampleSource.
This fixes an issue where the PsExtractor would start reading unsynchronized if sniff was called. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117958077
This commit is contained in:
parent
1175f50fb8
commit
8571c81076
@ -26,7 +26,7 @@ import java.io.IOException;
|
|||||||
public interface ExtractorInput {
|
public interface ExtractorInput {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads up to {@code length} bytes from the input.
|
* Reads up to {@code length} bytes from the input and resets the peek position.
|
||||||
* <p>
|
* <p>
|
||||||
* This method blocks until at least one byte of data can be read, the end of the input is
|
* This method blocks until at least one byte of data can be read, the end of the input is
|
||||||
* detected, or an exception is thrown.
|
* detected, or an exception is thrown.
|
||||||
@ -128,7 +128,7 @@ public interface ExtractorInput {
|
|||||||
* Otherwise an {@link EOFException} is thrown.
|
* Otherwise an {@link EOFException} is thrown.
|
||||||
* <p>
|
* <p>
|
||||||
* Calling {@link #resetPeekPosition()} resets the peek position to equal the current read
|
* Calling {@link #resetPeekPosition()} resets the peek position to equal the current read
|
||||||
* position, so the caller can peek the same data again. Reading and skipping also reset the peek
|
* position, so the caller can peek the same data again. Reading or skipping also resets the peek
|
||||||
* position.
|
* position.
|
||||||
*
|
*
|
||||||
* @param target A target array into which data should be written.
|
* @param target A target array into which data should be written.
|
||||||
|
@ -892,8 +892,9 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
|
|||||||
}
|
}
|
||||||
} catch (EOFException e) {
|
} catch (EOFException e) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
|
} finally {
|
||||||
|
input.resetPeekPosition();
|
||||||
}
|
}
|
||||||
input.resetPeekPosition();
|
|
||||||
}
|
}
|
||||||
if (extractor == null) {
|
if (extractor == null) {
|
||||||
throw new UnrecognizedInputFormatException(extractors);
|
throw new UnrecognizedInputFormatException(extractors);
|
||||||
|
@ -72,7 +72,6 @@ public final class OggVorbisExtractor implements Extractor, SeekMap {
|
|||||||
} catch (ParserException e) {
|
} catch (ParserException e) {
|
||||||
// does not happen
|
// does not happen
|
||||||
} finally {
|
} finally {
|
||||||
input.resetPeekPosition();
|
|
||||||
scratch.reset();
|
scratch.reset();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -147,15 +147,14 @@ import java.util.Stack;
|
|||||||
*/
|
*/
|
||||||
private long maybeResyncToNextLevel1Element(ExtractorInput input) throws EOFException,
|
private long maybeResyncToNextLevel1Element(ExtractorInput input) throws EOFException,
|
||||||
IOException, InterruptedException {
|
IOException, InterruptedException {
|
||||||
|
input.resetPeekPosition();
|
||||||
while (true) {
|
while (true) {
|
||||||
input.resetPeekPosition();
|
|
||||||
input.peekFully(scratch, 0, MAX_ID_BYTES);
|
input.peekFully(scratch, 0, MAX_ID_BYTES);
|
||||||
int varintLength = VarintReader.parseUnsignedVarintLength(scratch[0]);
|
int varintLength = VarintReader.parseUnsignedVarintLength(scratch[0]);
|
||||||
if (varintLength != -1 && varintLength <= MAX_ID_BYTES) {
|
if (varintLength != -1 && varintLength <= MAX_ID_BYTES) {
|
||||||
int potentialId = (int) VarintReader.assembleVarint(scratch, varintLength, false);
|
int potentialId = (int) VarintReader.assembleVarint(scratch, varintLength, false);
|
||||||
if (output.isLevel1Element(potentialId)) {
|
if (output.isLevel1Element(potentialId)) {
|
||||||
input.skipFully(varintLength);
|
input.skipFully(varintLength);
|
||||||
input.resetPeekPosition();
|
|
||||||
return potentialId;
|
return potentialId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user