Bug 1673525 - Don't try and process audio with no frames in DecodedStream. r=pehrsons

Differential Revision: https://phabricator.services.mozilla.com/D100400
This commit is contained in:
Bryce Seager van Dyk 2021-01-11 20:24:03 +00:00
parent a42d59200f
commit c2d4dcad38

View File

@ -608,6 +608,11 @@ static void SendStreamAudio(DecodedStreamData* aStream,
MOZ_ASSERT(aData);
AudioData* audio = aData;
if (!audio->Frames()) {
// Ignore elements with 0 frames.
return;
}
// This logic has to mimic AudioSink closely to make sure we write
// the exact same silences
CheckedInt64 audioWrittenOffset =
@ -621,8 +626,9 @@ static void SendStreamAudio(DecodedStreamData* aStream,
}
if (audioWrittenOffset.value() + AUDIO_FUZZ_FRAMES < frameOffset.value()) {
// We've written less audio than our frame offset, write silence so we have
// enough audio to be at the correct offset for our current frames.
int64_t silentFrames = frameOffset.value() - audioWrittenOffset.value();
// Write silence to catch up
AudioSegment silence;
silence.InsertNullDataAtStart(silentFrames);
aStream->mAudioFramesWritten += silentFrames;