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

Side by Side Diff: webrtc/voice_engine/audio_level.cc

Issue 2750783004: Add mute state field to AudioFrame. (Closed)
Patch Set: Update new usages of AudioFrame::data_ Created 3 years, 6 months 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
« no previous file with comments | « webrtc/voice_engine/BUILD.gn ('k') | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « webrtc/voice_engine/BUILD.gn ('k') | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698