mirror of
https://github.com/samsonjs/media.git
synced 2026-04-26 14:57:47 +00:00
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
This commit is contained in:
parent
541568386b
commit
513b268558
1 changed files with 5 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue