Bug 1480161: Fix underrun assert for processed input stream. r=achronop

The logic here intends to (as is written in the comment) append one block of
silence to the track to allow for us to underrun one full scratch buffer.

The code doesn't match this behavior however, because if we are not underrunning
by less than a block, we end up appending *less* than a block. This causes us to
append at a later time as the scratch buffer can swallow more (up to a full
block) than we appended.

Without processing this seems to work because of timing and ordering, but
with processing (aec/agc/ns) we tend to add 71
(512 for an iteration - 441 packed) samples of silence,
leaving us to hit the assert with a 44% ((128-71)/128) chance during subsequent
iterations.

Differential Revision: https://phabricator.services.mozilla.com/D2644

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2018-08-02 10:25:05 +00:00
Родитель ab37a52582
Коммит 0facadf342
1 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -805,6 +805,12 @@ MediaEngineWebRTCMicrophoneSource::Pull(const RefPtr<const AllocationHandle>& aH
// allocation was removed and the track non-existant. An assert will fail.
delta = aDesiredTime - aStream->GetEndOfAppendedData(aTrackID);
if (delta < 0) {
LOG_FRAMES(("Not appending silence for allocation %p; %" PRId64 " frames already buffered",
mAllocations[i].mHandle.get(), -delta));
return;
}
if (!mAllocations[i].mLiveFramesAppended ||
!mAllocations[i].mLiveSilenceAppended) {
// These are the iterations after starting or resuming audio capture.
@ -815,12 +821,6 @@ MediaEngineWebRTCMicrophoneSource::Pull(const RefPtr<const AllocationHandle>& aH
delta += WEBAUDIO_BLOCK_SIZE;
}
if (delta < 0) {
LOG_FRAMES(("Not appending silence for allocation %p; %" PRId64 " frames already buffered",
mAllocations[i].mHandle.get(), -delta));
return;
}
LOG_FRAMES(("Pulling %" PRId64 " frames of silence for allocation %p",
delta, mAllocations[i].mHandle.get()));