mirror of
https://github.com/androidx/media.git
synced 2025-05-05 22:50:57 +08:00
Mp3Extractor: Avoid outputting non-zero position seek frame as a sample
Checking inputPosition == 0 isn't sufficient because the synchronization at the top of read() may advance the input (i.e. in the case where there's some garbage prior to the seek frame). PiperOrigin-RevId: 261086901
This commit is contained in:
parent
3e99e7af54
commit
e159e3acd0
@ -117,7 +117,7 @@ public final class Mp3Extractor implements Extractor {
|
|||||||
private Seeker seeker;
|
private Seeker seeker;
|
||||||
private long basisTimeUs;
|
private long basisTimeUs;
|
||||||
private long samplesRead;
|
private long samplesRead;
|
||||||
private int firstSamplePosition;
|
private long firstSamplePosition;
|
||||||
private int sampleBytesRemaining;
|
private int sampleBytesRemaining;
|
||||||
|
|
||||||
public Mp3Extractor() {
|
public Mp3Extractor() {
|
||||||
@ -215,10 +215,13 @@ public final class Mp3Extractor implements Extractor {
|
|||||||
/* selectionFlags= */ 0,
|
/* selectionFlags= */ 0,
|
||||||
/* language= */ null,
|
/* language= */ null,
|
||||||
(flags & FLAG_DISABLE_ID3_METADATA) != 0 ? null : metadata));
|
(flags & FLAG_DISABLE_ID3_METADATA) != 0 ? null : metadata));
|
||||||
firstSamplePosition = (int) input.getPosition();
|
firstSamplePosition = input.getPosition();
|
||||||
} else if (input.getPosition() == 0 && firstSamplePosition != 0) {
|
} else if (firstSamplePosition != 0) {
|
||||||
// Skip past the seek frame.
|
long inputPosition = input.getPosition();
|
||||||
input.skipFully(firstSamplePosition);
|
if (inputPosition < firstSamplePosition) {
|
||||||
|
// Skip past the seek frame.
|
||||||
|
input.skipFully((int) (firstSamplePosition - inputPosition));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return readSample(input);
|
return readSample(input);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user