OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // shrink the amount of slack the compressor provides. | 400 // shrink the amount of slack the compressor provides. |
401 int residual_gain = rms_error - raw_compression; | 401 int residual_gain = rms_error - raw_compression; |
402 residual_gain = std::min(std::max(residual_gain, -kMaxResidualGainChange), | 402 residual_gain = std::min(std::max(residual_gain, -kMaxResidualGainChange), |
403 kMaxResidualGainChange); | 403 kMaxResidualGainChange); |
404 LOG(LS_INFO) << "[agc] rms_error=" << rms_error << ", " | 404 LOG(LS_INFO) << "[agc] rms_error=" << rms_error << ", " |
405 << "target_compression=" << target_compression_ << ", " | 405 << "target_compression=" << target_compression_ << ", " |
406 << "residual_gain=" << residual_gain; | 406 << "residual_gain=" << residual_gain; |
407 if (residual_gain == 0) | 407 if (residual_gain == 0) |
408 return; | 408 return; |
409 | 409 |
| 410 int old_level = level_; |
410 SetLevel(LevelFromGainError(residual_gain, level_)); | 411 SetLevel(LevelFromGainError(residual_gain, level_)); |
| 412 if (old_level != level_) { |
| 413 // level_ was updated by SetLevel; log the new value. |
| 414 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.AgcLevel", level_, kMaxMicLevel); |
| 415 } |
411 } | 416 } |
412 | 417 |
413 void AgcManagerDirect::UpdateCompressor() { | 418 void AgcManagerDirect::UpdateCompressor() { |
414 if (compression_ == target_compression_) { | 419 if (compression_ == target_compression_) { |
415 return; | 420 return; |
416 } | 421 } |
417 | 422 |
418 // Adapt the compression gain slowly towards the target, in order to avoid | 423 // Adapt the compression gain slowly towards the target, in order to avoid |
419 // highly perceptible changes. | 424 // highly perceptible changes. |
420 if (target_compression_ > compression_) { | 425 if (target_compression_ > compression_) { |
(...skipping 17 matching lines...) Expand all Loading... |
438 compression_ = new_compression; | 443 compression_ = new_compression; |
439 compression_accumulator_ = new_compression; | 444 compression_accumulator_ = new_compression; |
440 if (gctrl_->set_compression_gain_db(compression_) != 0) { | 445 if (gctrl_->set_compression_gain_db(compression_) != 0) { |
441 LOG(LS_ERROR) << "set_compression_gain_db(" << compression_ | 446 LOG(LS_ERROR) << "set_compression_gain_db(" << compression_ |
442 << ") failed."; | 447 << ") failed."; |
443 } | 448 } |
444 } | 449 } |
445 } | 450 } |
446 | 451 |
447 } // namespace webrtc | 452 } // namespace webrtc |
OLD | NEW |