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

Side by Side Diff: webrtc/modules/audio_processing/level_estimator_impl.cc

Issue 2535523002: Refactor RMSLevel and give it new functionality (Closed)
Patch Set: Fixing win64 compile Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 void LevelEstimatorImpl::ProcessStream(AudioBuffer* audio) { 31 void LevelEstimatorImpl::ProcessStream(AudioBuffer* audio) {
32 RTC_DCHECK(audio); 32 RTC_DCHECK(audio);
33 rtc::CritScope cs(crit_); 33 rtc::CritScope cs(crit_);
34 if (!enabled_) { 34 if (!enabled_) {
35 return; 35 return;
36 } 36 }
37 37
38 for (size_t i = 0; i < audio->num_channels(); i++) { 38 for (size_t i = 0; i < audio->num_channels(); i++) {
39 rms_->Process(audio->channels_const()[i], audio->num_frames()); 39 rms_->Process(rtc::ArrayView<const int16_t>(audio->channels_const()[i],
40 audio->num_frames()));
40 } 41 }
41 } 42 }
42 43
43 int LevelEstimatorImpl::Enable(bool enable) { 44 int LevelEstimatorImpl::Enable(bool enable) {
44 rtc::CritScope cs(crit_); 45 rtc::CritScope cs(crit_);
45 if (enable && !enabled_) { 46 if (enable && !enabled_) {
46 rms_->Reset(); 47 rms_->Reset();
47 } 48 }
48 enabled_ = enable; 49 enabled_ = enable;
49 return AudioProcessing::kNoError; 50 return AudioProcessing::kNoError;
50 } 51 }
51 52
52 bool LevelEstimatorImpl::is_enabled() const { 53 bool LevelEstimatorImpl::is_enabled() const {
53 rtc::CritScope cs(crit_); 54 rtc::CritScope cs(crit_);
54 return enabled_; 55 return enabled_;
55 } 56 }
56 57
57 int LevelEstimatorImpl::RMS() { 58 int LevelEstimatorImpl::RMS() {
58 rtc::CritScope cs(crit_); 59 rtc::CritScope cs(crit_);
59 if (!enabled_) { 60 if (!enabled_) {
60 return AudioProcessing::kNotEnabledError; 61 return AudioProcessing::kNotEnabledError;
61 } 62 }
62 63
63 return rms_->RMS(); 64 return rms_->RMS();
64 } 65 }
65 } // namespace webrtc 66 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/rms_level.h » ('j') | webrtc/modules/audio_processing/rms_level.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698