From 9962c2e6afdfd5913b17f563b364563fa7edfb7d Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Tue, 15 Sep 2020 14:41:56 +0000 Subject: [PATCH] Bug 1656438 - Only raise the FramesProcessedEvent once there is no silence. r=padenot Because an audio driver starts out with its fallback driver running the graph, we might use unnecessary amounts of silence for the verification. Especially with the `GoFaster()` mode turned on, as the fallback driver's thread runs rarely compared to how often we are feeding the graph audio data from the MockCubebStream. Differential Revision: https://phabricator.services.mozilla.com/D89753 --- dom/media/gtest/AudioVerifier.h | 3 +++ dom/media/gtest/MockCubeb.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dom/media/gtest/AudioVerifier.h b/dom/media/gtest/AudioVerifier.h index e5248b0bf98d..624aad05ba60 100644 --- a/dom/media/gtest/AudioVerifier.h +++ b/dom/media/gtest/AudioVerifier.h @@ -56,6 +56,9 @@ class AudioVerifier { sin(2 * M_PI * mFrequency / mRate)); } + bool PreSilenceEnded() const { + return mTotalFramesSoFar > mPreSilenceSamples; + } uint64_t PreSilenceSamples() const { return mPreSilenceSamples; } uint32_t CountDiscontinuities() const { return mDiscontinuitiesCount; } diff --git a/dom/media/gtest/MockCubeb.h b/dom/media/gtest/MockCubeb.h index 9115dc4c70a3..1255a1dc6b70 100644 --- a/dom/media/gtest/MockCubeb.h +++ b/dom/media/gtest/MockCubeb.h @@ -225,7 +225,9 @@ class MockCubebStream { mAudioVerifier.AppendDataInterleaved(mOutputBuffer, outframes, NUM_OF_CHANNELS); - mFramesProcessedEvent.Notify(outframes); + if (mAudioVerifier.PreSilenceEnded()) { + mFramesProcessedEvent.Notify(outframes); + } if (outframes < NUM_OF_FRAMES) { mStateCallback(stream, mUserPtr, CUBEB_STATE_DRAINED);