Fix intermittent decoder crash when playing MP3 inside MP4

This commit is contained in:
Oliver Woodman 2015-06-26 16:53:46 +01:00
parent 3bcd9ca6c3
commit 588be2bd4b
4 changed files with 10 additions and 16 deletions

View File

@ -30,7 +30,6 @@ import com.google.android.exoplayer.util.Util;
import java.io.EOFException;
import java.io.IOException;
import java.util.Collections;
/**
* Extracts data from an MP3 file.
@ -247,7 +246,7 @@ public final class Mp3Extractor implements Extractor {
extractorOutput.seekMap(seeker);
trackOutput.format(MediaFormat.createAudioFormat(synchronizedHeader.mimeType,
MpegAudioHeader.MAX_FRAME_SIZE_BYTES, seeker.getDurationUs(), synchronizedHeader.channels,
synchronizedHeader.sampleRate, Collections.<byte[]>emptyList()));
synchronizedHeader.sampleRate, null));
}
return headerPosition;

View File

@ -471,8 +471,7 @@ import java.util.List;
}
}
List<byte[]> initializationData = csdLength == 0 ? Collections.<byte[]>emptyList()
: Collections.singletonList(buffer);
List<byte[]> initializationData = csdLength == 0 ? null : Collections.singletonList(buffer);
return Pair.create(initializationData, lengthSizeMinusOne + 1);
}
@ -628,6 +627,10 @@ import java.util.List;
int objectTypeIndication = parent.readUnsignedByte();
String mimeType;
switch (objectTypeIndication) {
case 0x6B:
mimeType = MimeTypes.AUDIO_MPEG;
// Don't extract codec-specific data for MPEG audio tracks, as it is not needed.
return Pair.create(mimeType, null);
case 0x20:
mimeType = MimeTypes.VIDEO_MP4V;
break;
@ -640,9 +643,6 @@ import java.util.List;
case 0x40:
mimeType = MimeTypes.AUDIO_AAC;
break;
case 0x6B:
mimeType = MimeTypes.AUDIO_MPEG;
break;
case 0xA5:
mimeType = MimeTypes.AUDIO_AC3;
break;

View File

@ -21,8 +21,6 @@ import com.google.android.exoplayer.extractor.TrackOutput;
import com.google.android.exoplayer.util.MpegAudioHeader;
import com.google.android.exoplayer.util.ParsableByteArray;
import java.util.Collections;
/**
* Parses a continuous MPEG Audio byte stream and extracts individual frames.
*/
@ -164,7 +162,7 @@ import java.util.Collections;
frameDurationUs = (C.MICROS_PER_SECOND * header.samplesPerFrame) / header.sampleRate;
MediaFormat mediaFormat = MediaFormat.createAudioFormat(header.mimeType,
MpegAudioHeader.MAX_FRAME_SIZE_BYTES, C.UNKNOWN_TIME_US, header.channels,
header.sampleRate, Collections.<byte[]>emptyList());
header.sampleRate, null);
output.format(mediaFormat);
hasOutputFormat = true;
}

View File

@ -17,8 +17,6 @@ package com.google.android.exoplayer.util;
import com.google.android.exoplayer.MediaFormat;
import java.util.Collections;
/**
* Utility methods for parsing AC-3 headers.
*/
@ -51,7 +49,7 @@ public final class Ac3Util {
channelCount++;
}
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
channelCount, sampleRate, Collections.<byte[]>emptyList());
channelCount, sampleRate, null);
}
/**
@ -74,7 +72,7 @@ public final class Ac3Util {
channelCount++;
}
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE,
channelCount, sampleRate, Collections.<byte[]>emptyList());
channelCount, sampleRate, null);
}
/**
@ -102,8 +100,7 @@ public final class Ac3Util {
}
boolean lfeon = data.readBit();
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
CHANNEL_COUNTS[acmod] + (lfeon ? 1 : 0), SAMPLE_RATES[fscod],
Collections.<byte[]>emptyList());
CHANNEL_COUNTS[acmod] + (lfeon ? 1 : 0), SAMPLE_RATES[fscod], null);
}
/**