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 bool SetAutomaticGainControl(bool enabled) override { | 141 bool 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 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 // Gets the current automatic gain control state. | 148 // Gets the current automatic gain control state. |
149 virtual bool GetAutomaticGainControl() override { | 149 bool GetAutomaticGainControl() override { |
150 DCHECK(thread_checker_.CalledOnValidThread()); | 150 DCHECK(thread_checker_.CalledOnValidThread()); |
151 return agc_is_enabled_; | 151 return agc_is_enabled_; |
152 } | 152 } |
153 | 153 |
154 // Takes a new microphone volume sample and stores it in |normalized_volume_|. | 154 // Takes a new microphone volume sample and stores it in |normalized_volume_|. |
155 // Range is normalized to [0.0,1.0] or [0.0, 1.5] on Linux. | 155 // Range is normalized to [0.0,1.0] or [0.0, 1.5] on Linux. |
156 // This method is called periodically when AGC is enabled and always on the | 156 // This method is called periodically when AGC is enabled and always on the |
157 // audio manager thread. We use it to read the current microphone level and | 157 // audio manager thread. We use it to read the current microphone level and |
158 // to store it so it can be read by the main capture thread. By using this | 158 // to store it so it can be read by the main capture thread. By using this |
159 // approach, we can avoid accessing audio hardware from a real-time audio | 159 // 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... |
196 | 196 |
197 // Protects |normalized_volume_| . | 197 // Protects |normalized_volume_| . |
198 base::Lock lock_; | 198 base::Lock lock_; |
199 | 199 |
200 DISALLOW_COPY_AND_ASSIGN(AgcAudioStream<AudioInterface>); | 200 DISALLOW_COPY_AND_ASSIGN(AgcAudioStream<AudioInterface>); |
201 }; | 201 }; |
202 | 202 |
203 } // namespace media | 203 } // namespace media |
204 | 204 |
205 #endif // MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ | 205 #endif // MEDIA_AUDIO_AGC_AUDIO_STREAM_H_ |
OLD | NEW |