Commit 513b2685 by krocard Committed by Oliver Woodman

Detect invalid frames early in passthrough/offload

Without checking if getFramesPerEncodedSample fails,
the frame count becomes negative which leads to
hard to debug errors.

PiperOrigin-RevId: 319247618
parent 54156838
......@@ -1402,7 +1402,11 @@ public final class DefaultAudioSink implements AudioSink {
switch (encoding) {
case C.ENCODING_MP3:
int headerDataInBigEndian = Util.getBigEndianInt(buffer, buffer.position());
return MpegAudioUtil.parseMpegAudioFrameSampleCount(headerDataInBigEndian);
int frameCount = MpegAudioUtil.parseMpegAudioFrameSampleCount(headerDataInBigEndian);
if (frameCount == C.LENGTH_UNSET) {
throw new IllegalArgumentException();
}
return frameCount;
case C.ENCODING_AAC_LC:
return AacUtil.AAC_LC_AUDIO_SAMPLE_COUNT;
case C.ENCODING_AAC_HE_V1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment