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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 rewind(near_file_); | 673 rewind(near_file_); |
674 while (!frame_queue.empty()) { | 674 while (!frame_queue.empty()) { |
675 AudioFrame* frame = frame_queue.front(); | 675 AudioFrame* frame = frame_queue.front(); |
676 frame_queue.pop(); | 676 frame_queue.pop(); |
677 delete frame; | 677 delete frame; |
678 } | 678 } |
679 // Calculate expected delay estimate and acceptable regions. Further, | 679 // Calculate expected delay estimate and acceptable regions. Further, |
680 // limit them w.r.t. AEC delay estimation support. | 680 // limit them w.r.t. AEC delay estimation support. |
681 const size_t samples_per_ms = | 681 const size_t samples_per_ms = |
682 rtc::SafeMin<size_t>(16u, frame_->samples_per_channel_ / 10); | 682 rtc::SafeMin<size_t>(16u, frame_->samples_per_channel_ / 10); |
683 int expected_median = std::min(std::max(delay_ms - system_delay_ms, | 683 const int expected_median = |
684 delay_min), delay_max); | 684 rtc::SafeClamp<int>(delay_ms - system_delay_ms, delay_min, delay_max); |
685 int expected_median_high = std::min( | 685 const int expected_median_high = rtc::SafeClamp<int>( |
686 std::max(expected_median + static_cast<int>(96 / samples_per_ms), | 686 expected_median + rtc::dchecked_cast<int>(96 / samples_per_ms), delay_min, |
687 delay_min), | |
688 delay_max); | 687 delay_max); |
689 int expected_median_low = std::min( | 688 const int expected_median_low = rtc::SafeClamp<int>( |
690 std::max(expected_median - static_cast<int>(96 / samples_per_ms), | 689 expected_median - rtc::dchecked_cast<int>(96 / samples_per_ms), delay_min, |
691 delay_min), | |
692 delay_max); | 690 delay_max); |
693 // Verify delay metrics. | 691 // Verify delay metrics. |
694 int median; | 692 int median; |
695 int std; | 693 int std; |
696 float poor_fraction; | 694 float poor_fraction; |
697 EXPECT_EQ(apm_->kNoError, | 695 EXPECT_EQ(apm_->kNoError, |
698 apm_->echo_cancellation()->GetDelayMetrics(&median, &std, | 696 apm_->echo_cancellation()->GetDelayMetrics(&median, &std, |
699 &poor_fraction)); | 697 &poor_fraction)); |
700 EXPECT_GE(expected_median_high, median); | 698 EXPECT_GE(expected_median_high, median); |
701 EXPECT_LE(expected_median_low, median); | 699 EXPECT_LE(expected_median_low, median); |
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 // TODO(peah): Remove the testing for | 2874 // TODO(peah): Remove the testing for |
2877 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | 2875 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
2878 // is instead used to activate the level controller. | 2876 // is instead used to activate the level controller. |
2879 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | 2877 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
2880 EXPECT_NEAR(kTargetLcPeakLeveldBFS, | 2878 EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
2881 apm->config_.level_controller.initial_peak_level_dbfs, | 2879 apm->config_.level_controller.initial_peak_level_dbfs, |
2882 std::numeric_limits<float>::epsilon()); | 2880 std::numeric_limits<float>::epsilon()); |
2883 } | 2881 } |
2884 | 2882 |
2885 } // namespace webrtc | 2883 } // namespace webrtc |
OLD | NEW |