| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 28 rms_->Reset(); | 28 rms_->Reset(); |
| 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 (int 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(audio->channels_const()[i], audio->num_frames()); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 int LevelEstimatorImpl::Enable(bool enable) { | 43 int LevelEstimatorImpl::Enable(bool enable) { |
| 44 rtc::CritScope cs(crit_); | 44 rtc::CritScope cs(crit_); |
| 45 if (enable && !enabled_) { | 45 if (enable && !enabled_) { |
| 46 rms_->Reset(); | 46 rms_->Reset(); |
| 47 } | 47 } |
| 48 enabled_ = enable; | 48 enabled_ = enable; |
| 49 return AudioProcessing::kNoError; | 49 return AudioProcessing::kNoError; |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool LevelEstimatorImpl::is_enabled() const { | 52 bool LevelEstimatorImpl::is_enabled() const { |
| 53 rtc::CritScope cs(crit_); | 53 rtc::CritScope cs(crit_); |
| 54 return enabled_; | 54 return enabled_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 int LevelEstimatorImpl::RMS() { | 57 int LevelEstimatorImpl::RMS() { |
| 58 rtc::CritScope cs(crit_); | 58 rtc::CritScope cs(crit_); |
| 59 if (!enabled_) { | 59 if (!enabled_) { |
| 60 return AudioProcessing::kNotEnabledError; | 60 return AudioProcessing::kNotEnabledError; |
| 61 } | 61 } |
| 62 | 62 |
| 63 return rms_->RMS(); | 63 return rms_->RMS(); |
| 64 } | 64 } |
| 65 } // namespace webrtc | 65 } // namespace webrtc |
| OLD | NEW |