Skip to content

Commit

Permalink
Read until the track formats are available in TestUtil.extractSeekMap()
Browse files Browse the repository at this point in the history
Otherwise, some extractor tests are seeking without making sure that the
extractor has retrieved the formats.

This is needed for PR Issue: #7378.

PiperOrigin-RevId: 335934326
  • Loading branch information
kim-vde authored and ojw28 committed Oct 20, 2020
1 parent 452f68f commit efaa296
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ public static Uri buildAssetUri(String assetPath) {

/**
* Reads from the given input using the given {@link Extractor}, until it can produce the {@link
* SeekMap} and all of the tracks have been identified, or until the extractor encounters EOF.
* SeekMap} and all of the track formats have been identified, or until the extractor encounters
* EOF.
*
* @param extractor The {@link Extractor} to extractor from input.
* @param output The {@link FakeTrackOutput} to store the extracted {@link SeekMap} and track.
Expand All @@ -316,11 +317,18 @@ public static SeekMap extractSeekMap(
int readResult = Extractor.RESULT_CONTINUE;
while (true) {
try {
// Keep reading until we can get the seek map
// Keep reading until we get the seek map and the track information.
while (readResult == Extractor.RESULT_CONTINUE
&& (output.seekMap == null || !output.tracksEnded)) {
readResult = extractor.read(input, positionHolder);
}
for (int i = 0; i < output.trackOutputs.size(); i++) {
int trackId = output.trackOutputs.keyAt(i);
while (readResult == Extractor.RESULT_CONTINUE
&& output.trackOutputs.get(trackId).lastFormat == null) {
readResult = extractor.read(input, positionHolder);
}
}
} finally {
Util.closeQuietly(dataSource);
}
Expand Down

0 comments on commit efaa296

Please sign in to comment.