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

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

Issue 669393002: Merge 661693003 to M39: Avoid reporting 0 as input level when AudioProcessing zero out the audio da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2171
Patch Set: 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..9994b695e1182f443cd9635f40254c3457edc1ae 100644
--- a/content/renderer/media/media_stream_audio_level_calculator.cc
+++ b/content/renderer/media/media_stream_audio_level_calculator.cc
@@ -38,9 +38,11 @@ MediaStreamAudioLevelCalculator::MediaStreamAudioLevelCalculator()
MediaStreamAudioLevelCalculator::~MediaStreamAudioLevelCalculator() {
}
-int MediaStreamAudioLevelCalculator::Calculate(const int16* audio_data,
- int number_of_channels,
- int number_of_frames) {
+int MediaStreamAudioLevelCalculator::Calculate(
+ const int16* audio_data,
+ int number_of_channels,
+ int number_of_frames,
+ bool force_report_nonzero_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 +52,8 @@ int MediaStreamAudioLevelCalculator::Calculate(const int16* audio_data,
max_amplitude_ = std::max(max_amplitude_, max);
if (counter_++ == kUpdateFrequency) {
- level_ = max_amplitude_;
+ level_ = (max_amplitude_ == 0 ?
+ force_report_nonzero_energy : max_amplitude_);
// Decay the absolute maximum amplitude by 1/4.
max_amplitude_ >>= 2;
« no previous file with comments | « content/renderer/media/media_stream_audio_level_calculator.h ('k') | content/renderer/media/webaudio_capturer_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698