OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ | 5 #ifndef MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ |
6 #define MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ | 6 #define MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 base::AutoLock lock(lock_); | 131 base::AutoLock lock(lock_); |
132 *normalized_volume = normalized_volume_; | 132 *normalized_volume = normalized_volume_; |
133 } | 133 } |
134 | 134 |
135 private: | 135 private: |
136 // Sets the automatic gain control (AGC) to on or off. When AGC is enabled, | 136 // Sets the automatic gain control (AGC) to on or off. When AGC is enabled, |
137 // the microphone volume is queried periodically and the volume level can | 137 // the microphone volume is queried periodically and the volume level can |
138 // be read in each AudioInputCallback::OnData() callback and fed to the | 138 // be read in each AudioInputCallback::OnData() callback and fed to the |
139 // render-side AGC. User must call StartAgc() as well to start measuring | 139 // render-side AGC. User must call StartAgc() as well to start measuring |
140 // the microphone level. | 140 // the microphone level. |
141 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE { | 141 virtual void SetAutomaticGainControl(bool enabled) override { |
142 DVLOG(1) << "SetAutomaticGainControl(enabled=" << enabled << ")"; | 142 DVLOG(1) << "SetAutomaticGainControl(enabled=" << enabled << ")"; |
143 DCHECK(thread_checker_.CalledOnValidThread()); | 143 DCHECK(thread_checker_.CalledOnValidThread()); |
144 agc_is_enabled_ = enabled; | 144 agc_is_enabled_ = enabled; |
145 } | 145 } |
146 | 146 |
147 // Gets the current automatic gain control state. | 147 // Gets the current automatic gain control state. |
148 virtual bool GetAutomaticGainControl() OVERRIDE { | 148 virtual bool GetAutomaticGainControl() override { |
149 DCHECK(thread_checker_.CalledOnValidThread()); | 149 DCHECK(thread_checker_.CalledOnValidThread()); |
150 return agc_is_enabled_; | 150 return agc_is_enabled_; |
151 } | 151 } |
152 | 152 |
153 // Takes a new microphone volume sample and stores it in |normalized_volume_|. | 153 // Takes a new microphone volume sample and stores it in |normalized_volume_|. |
154 // Range is normalized to [0.0,1.0] or [0.0, 1.5] on Linux. | 154 // Range is normalized to [0.0,1.0] or [0.0, 1.5] on Linux. |
155 // This method is called periodically when AGC is enabled and always on the | 155 // This method is called periodically when AGC is enabled and always on the |
156 // audio manager thread. We use it to read the current microphone level and | 156 // audio manager thread. We use it to read the current microphone level and |
157 // to store it so it can be read by the main capture thread. By using this | 157 // to store it so it can be read by the main capture thread. By using this |
158 // approach, we can avoid accessing audio hardware from a real-time audio | 158 // approach, we can avoid accessing audio hardware from a real-time audio |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 // Protects |normalized_volume_| . | 196 // Protects |normalized_volume_| . |
197 base::Lock lock_; | 197 base::Lock lock_; |
198 | 198 |
199 DISALLOW_COPY_AND_ASSIGN(AgcAudioStream<AudioInterface>); | 199 DISALLOW_COPY_AND_ASSIGN(AgcAudioStream<AudioInterface>); |
200 }; | 200 }; |
201 | 201 |
202 } // namespace media | 202 } // namespace media |
203 | 203 |
204 #endif // MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ | 204 #endif // MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ |
OLD | NEW |