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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void AudioLevel::Clear() { | 43 void AudioLevel::Clear() { |
44 rtc::CritScope cs(&crit_sect_); | 44 rtc::CritScope cs(&crit_sect_); |
45 abs_max_ = 0; | 45 abs_max_ = 0; |
46 count_ = 0; | 46 count_ = 0; |
47 current_level_ = 0; | 47 current_level_ = 0; |
48 current_level_full_range_ = 0; | 48 current_level_full_range_ = 0; |
49 } | 49 } |
50 | 50 |
51 void AudioLevel::ComputeLevel(const AudioFrame& audioFrame) { | 51 void AudioLevel::ComputeLevel(const AudioFrame& audioFrame) { |
52 // Check speech level (works for 2 channels as well) | 52 // Check speech level (works for 2 channels as well) |
53 int16_t abs_value = WebRtcSpl_MaxAbsValueW16( | 53 int16_t abs_value = audioFrame.muted() ? 0 : |
54 audioFrame.data_, | 54 WebRtcSpl_MaxAbsValueW16( |
55 audioFrame.samples_per_channel_ * audioFrame.num_channels_); | 55 audioFrame.data(), |
| 56 audioFrame.samples_per_channel_ * audioFrame.num_channels_); |
56 | 57 |
57 // Protect member access using a lock since this method is called on a | 58 // Protect member access using a lock since this method is called on a |
58 // dedicated audio thread in the RecordedDataIsAvailable() callback. | 59 // dedicated audio thread in the RecordedDataIsAvailable() callback. |
59 rtc::CritScope cs(&crit_sect_); | 60 rtc::CritScope cs(&crit_sect_); |
60 | 61 |
61 if (abs_value > abs_max_) | 62 if (abs_value > abs_max_) |
62 abs_max_ = abs_value; | 63 abs_max_ = abs_value; |
63 | 64 |
64 // Update level approximately 10 times per second | 65 // Update level approximately 10 times per second |
65 if (count_++ == kUpdateFrequency) { | 66 if (count_++ == kUpdateFrequency) { |
(...skipping 13 matching lines...) Expand all Loading... |
79 } | 80 } |
80 current_level_ = kPermutation[position]; | 81 current_level_ = kPermutation[position]; |
81 | 82 |
82 // Decay the absolute maximum (divide by 4) | 83 // Decay the absolute maximum (divide by 4) |
83 abs_max_ >>= 2; | 84 abs_max_ >>= 2; |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 } // namespace voe | 88 } // namespace voe |
88 } // namespace webrtc | 89 } // namespace webrtc |
OLD | NEW |