diff --git a/dom/media/gtest/AudioVerifier.h b/dom/media/gtest/AudioVerifier.h index 12920529dbee..e50c812f63eb 100644 --- a/dom/media/gtest/AudioVerifier.h +++ b/dom/media/gtest/AudioVerifier.h @@ -42,7 +42,7 @@ class AudioVerifier { } } - uint32_t EstimatedFreq() const { + float EstimatedFreq() const { if (mTotalFramesSoFar == PreSilenceSamples()) { return 0; } @@ -52,7 +52,8 @@ class AudioVerifier { if (mZeroCrossCount <= 1) { return 0; } - return mRate / (mSumPeriodInSamples / (mZeroCrossCount - 1)); + return mRate / + (static_cast(mSumPeriodInSamples) / (mZeroCrossCount - 1)); } // Returns the maximum difference in value between two adjacent samples along diff --git a/dom/media/gtest/MockCubeb.h b/dom/media/gtest/MockCubeb.h index 76e7e3e1a9cf..e6e09596001d 100644 --- a/dom/media/gtest/MockCubeb.h +++ b/dom/media/gtest/MockCubeb.h @@ -171,7 +171,7 @@ class MockCubebStream { return mFramesProcessedEvent; } - MediaEventSource>& + MediaEventSource>& OutputVerificationEvent() { return mOutputVerificationEvent; } @@ -247,8 +247,7 @@ class MockCubebStream { AudioVerifier mAudioVerifier; MediaEventProducer mFramesProcessedEvent; - MediaEventProducer> - mOutputVerificationEvent; + MediaEventProducer> mOutputVerificationEvent; MediaEventProducer mErrorForcedEvent; }; diff --git a/dom/media/gtest/TestAudioDriftCorrection.cpp b/dom/media/gtest/TestAudioDriftCorrection.cpp index 6eb733456dc6..9c69084be13e 100644 --- a/dom/media/gtest/TestAudioDriftCorrection.cpp +++ b/dom/media/gtest/TestAudioDriftCorrection.cpp @@ -270,11 +270,11 @@ void testAudioCorrection(int32_t aSourceRate, int32_t aTargetRate) { EXPECT_NEAR(ad.CurrentBuffering(), ad.mDesiredBuffering - sampleRateTransmitter / 100, 512); - EXPECT_EQ(inToneVerifier.EstimatedFreq(), tone.mFrequency); + EXPECT_NEAR(inToneVerifier.EstimatedFreq(), tone.mFrequency, 1.0f); EXPECT_EQ(inToneVerifier.PreSilenceSamples(), 0U); EXPECT_EQ(inToneVerifier.CountDiscontinuities(), 0U); - EXPECT_EQ(outToneVerifier.EstimatedFreq(), tone.mFrequency); + EXPECT_NEAR(outToneVerifier.EstimatedFreq(), tone.mFrequency, 1.0f); // The expected pre-silence is 50ms plus the resampling. EXPECT_GE(outToneVerifier.PreSilenceSamples(), aTargetRate * 50 / 1000U); EXPECT_EQ(outToneVerifier.CountDiscontinuities(), 0U); diff --git a/dom/media/gtest/TestAudioTrackGraph.cpp b/dom/media/gtest/TestAudioTrackGraph.cpp index 74ecf91f472a..638b5b6e36db 100644 --- a/dom/media/gtest/TestAudioTrackGraph.cpp +++ b/dom/media/gtest/TestAudioTrackGraph.cpp @@ -453,12 +453,12 @@ void TestCrossGraphPort(uint32_t aInputRate, uint32_t aOutputRate, uint32_t partnerRate = partnerStream->InputSampleRate(); uint64_t preSilenceSamples; - uint32_t estimatedFreq; + float estimatedFreq; uint32_t nrDiscontinuities; Tie(preSilenceSamples, estimatedFreq, nrDiscontinuities) = WaitFor(partnerStream->OutputVerificationEvent()); - EXPECT_NEAR(estimatedFreq, inputFrequency, 10); + EXPECT_NEAR(estimatedFreq, inputFrequency / aDriftFactor, 5); EXPECT_GE(preSilenceSamples, partnerRate / 100 /* 10ms */); EXPECT_LE(nrDiscontinuities, 2U); }