Don't update currentTrackBundle until end of block

If currentTrackBundle is updated at the start of the
block and then something goes wrong in the middle (e.g.
one of the skipFully calls) then the extractor wont
resume from the correct place.

This would be caught by our extractor tests if we had
a test sample that requires skipping to the sample data.
I'll try and construct one of those.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131191174
This commit is contained in:
olly 2016-08-24 10:51:48 -07:00 committed by Oliver Woodman
parent 42efb5413a
commit abaa4f1aad

View file

@ -917,7 +917,7 @@ public final class FragmentedMp4Extractor implements Extractor {
private boolean readSample(ExtractorInput input) throws IOException, InterruptedException {
if (parserState == STATE_READING_SAMPLE_START) {
if (currentTrackBundle == null) {
currentTrackBundle = getNextFragmentRun(trackBundles);
TrackBundle currentTrackBundle = getNextFragmentRun(trackBundles);
if (currentTrackBundle == null) {
// We've run out of samples in the current mdat. Discard any trailing data and prepare to
// read the header of the next atom.
@ -938,6 +938,7 @@ public final class FragmentedMp4Extractor implements Extractor {
throw new ParserException("Offset to sample data was negative.");
}
input.skipFully(bytesToSkip);
this.currentTrackBundle = currentTrackBundle;
}
sampleSize = currentTrackBundle.fragment
.sampleSizeTable[currentTrackBundle.currentSampleIndex];