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

Unified Diff: content/renderer/media/media_stream_audio_level_calculator.cc

Issue 661693003: Avoid reporting 0 as input level when AudioProcessing zero out the audio data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed the unittests Created 6 years, 2 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
Index: content/renderer/media/media_stream_audio_level_calculator.cc
diff --git a/content/renderer/media/media_stream_audio_level_calculator.cc b/content/renderer/media/media_stream_audio_level_calculator.cc
index a136e32ae1009dbe87139f04a687a3a038d4ac69..33f3c5314b040fdf83e80b1801626fc3f94ae232 100644
--- a/content/renderer/media/media_stream_audio_level_calculator.cc
+++ b/content/renderer/media/media_stream_audio_level_calculator.cc
@@ -40,7 +40,8 @@ MediaStreamAudioLevelCalculator::~MediaStreamAudioLevelCalculator() {
int MediaStreamAudioLevelCalculator::Calculate(const int16* audio_data,
int number_of_channels,
- int number_of_frames) {
+ int number_of_frames,
+ bool has_energy) {
DCHECK(thread_checker_.CalledOnValidThread());
// |level_| is updated every 10 callbacks. For the case where callback comes
// every 10ms, |level_| will be updated approximately every 100ms.
@@ -50,7 +51,7 @@ int MediaStreamAudioLevelCalculator::Calculate(const int16* audio_data,
max_amplitude_ = std::max(max_amplitude_, max);
if (counter_++ == kUpdateFrequency) {
- level_ = max_amplitude_;
+ level_ = (max_amplitude_ == 0 ? has_energy : max_amplitude_);
// Decay the absolute maximum amplitude by 1/4.
max_amplitude_ >>= 2;

Powered by Google App Engine
This is Rietveld 408576698