Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1177)

Unified Diff: content/test/data/media/webrtc_test_audio.js

Issue 2366303002: Only look at the last 10K samples for WebRTC muting tests. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/media/webrtc_test_audio.js
diff --git a/content/test/data/media/webrtc_test_audio.js b/content/test/data/media/webrtc_test_audio.js
index 7bddd882222810345e067ddaf1d82d1fb25f06cb..858310d479db1160f692735b8e5b21e1bc82c8d5 100644
--- a/content/test/data/media/webrtc_test_audio.js
+++ b/content/test/data/media/webrtc_test_audio.js
@@ -134,12 +134,15 @@ function identifyFakeDeviceSignal_(samples) {
* @private
*/
function identifySilence_(samples) {
+ // Look at the last 10K samples only to make detection a bit faster.
+ var window = samples.slice(-10000);
+
var average = 0;
- for (var i = 0; i < samples.length; ++i)
- average += samples[i] / samples.length;
+ for (var i = 0; i < window.length; ++i)
+ average += window[i] / window.length;
// If silent (like when muted), we should get very near zero audio level.
- console.log('Average audio level: ' + average);
+ console.log('Average audio level (last 10k samples): ' + average);
return average < 0.01 * MAX_AUDIO_OUTPUT_ENERGY;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698