Bug 1656438 - Verify that the current buffer is close to the desired buffer in length. r=padenot

Depends on D89763

Differential Revision: https://phabricator.services.mozilla.com/D89764
This commit is contained in:
Andreas Pehrson 2020-09-15 11:55:57 +00:00
Родитель 37067e3c55
Коммит e74236a8b6
2 изменённых файлов: 12 добавлений и 3 удалений

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

@ -187,6 +187,9 @@ class AudioDriftCorrection final {
return output;
}
// Only accessible from the same thread that is driving RequestFrames().
uint32_t CurrentBuffering() const { return mResampler.InputDuration(); }
const int32_t mDesiredBuffering;
const int32_t mTargetRate;

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

@ -213,8 +213,8 @@ void testAudioCorrection(int32_t aSourceRate, int32_t aTargetRate) {
uint32_t sourceFrames;
const uint32_t targetFrames = sampleRateReceiver / 100;
// Run for some time: 6 * 250 = 1500 iterations
for (int j = 0; j < 6; ++j) {
// Run for some time: 3 * 1050 = 3150 iterations
for (int j = 0; j < 3; ++j) {
// apply some drift
if (j % 2 == 0) {
sourceFrames = sampleRateTransmitter / 100 + 10;
@ -222,7 +222,9 @@ void testAudioCorrection(int32_t aSourceRate, int32_t aTargetRate) {
sourceFrames = sampleRateTransmitter / 100 - 10;
}
for (int n = 0; n < 250; ++n) {
// 10.5 seconds, allows for at least 10 correction changes, to stabilize
// around the desired buffer.
for (int n = 0; n < 1050; ++n) {
// Create the input (sine tone)
AudioSegment inSegment;
tone.Generate(inSegment, sourceFrames);
@ -238,6 +240,10 @@ void testAudioCorrection(int32_t aSourceRate, int32_t aTargetRate) {
outToneVerifier.AppendData(outSegment);
}
}
EXPECT_NEAR(ad.CurrentBuffering(),
ad.mDesiredBuffering - sampleRateTransmitter / 100, 512);
EXPECT_EQ(inToneVerifier.EstimatedFreq(), tone.mFrequency);
EXPECT_EQ(inToneVerifier.PreSilenceSamples(), 0U);
EXPECT_EQ(inToneVerifier.CountDiscontinuities(), 0U);