Ensure we configure a new extractor when we need one.

Issue: #400
This commit is contained in:
Oliver Woodman 2015-05-11 21:03:30 +01:00
parent 770ad7f06f
commit b0abda43ec

View File

@ -243,16 +243,14 @@ public class HlsChunkSource {
public Chunk getChunkOperation(TsChunk previousTsChunk, long seekPositionUs, public Chunk getChunkOperation(TsChunk previousTsChunk, long seekPositionUs,
long playbackPositionUs) { long playbackPositionUs) {
int nextFormatIndex; int nextFormatIndex;
boolean switchingVariant;
boolean switchingVariantSpliced; boolean switchingVariantSpliced;
if (adaptiveMode == ADAPTIVE_MODE_NONE) { if (adaptiveMode == ADAPTIVE_MODE_NONE) {
nextFormatIndex = formatIndex; nextFormatIndex = formatIndex;
switchingVariant = false;
switchingVariantSpliced = false; switchingVariantSpliced = false;
} else { } else {
nextFormatIndex = getNextFormatIndex(previousTsChunk, playbackPositionUs); nextFormatIndex = getNextFormatIndex(previousTsChunk, playbackPositionUs);
switchingVariant = nextFormatIndex != formatIndex; switchingVariantSpliced = nextFormatIndex != formatIndex
switchingVariantSpliced = switchingVariant && adaptiveMode == ADAPTIVE_MODE_SPLICE; && adaptiveMode == ADAPTIVE_MODE_SPLICE;
} }
int variantIndex = getVariantIndex(enabledFormats[nextFormatIndex]); int variantIndex = getVariantIndex(enabledFormats[nextFormatIndex]);
@ -339,7 +337,8 @@ public class HlsChunkSource {
// Configure the extractor that will read the chunk. // Configure the extractor that will read the chunk.
HlsExtractorWrapper extractorWrapper; HlsExtractorWrapper extractorWrapper;
if (previousTsChunk == null || segment.discontinuity || switchingVariant || liveDiscontinuity) { if (previousTsChunk == null || segment.discontinuity || !format.equals(previousTsChunk.format)
|| liveDiscontinuity) {
Extractor extractor = chunkUri.getLastPathSegment().endsWith(AAC_FILE_EXTENSION) Extractor extractor = chunkUri.getLastPathSegment().endsWith(AAC_FILE_EXTENSION)
? new AdtsExtractor(startTimeUs) ? new AdtsExtractor(startTimeUs)
: new TsExtractor(startTimeUs, audioCapabilities); : new TsExtractor(startTimeUs, audioCapabilities);