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

Side by Side Diff: media/audio/agc_audio_stream.h

Issue 1487393003: Adding AGC stats in combination with report of missing input audio on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding XML part Created 5 years 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
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 // Gets the latest stored volume level if AGC is enabled. 127 // Gets the latest stored volume level if AGC is enabled.
128 // Called at each capture callback on a real-time capture thread (platform 128 // Called at each capture callback on a real-time capture thread (platform
129 // dependent). 129 // dependent).
130 void GetAgcVolume(double* normalized_volume) { 130 void GetAgcVolume(double* normalized_volume) {
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 // Gets the current automatic gain control state.
136 bool GetAutomaticGainControl() override {
137 DCHECK(thread_checker_.CalledOnValidThread());
138 return agc_is_enabled_;
139 }
140
135 private: 141 private:
136 // Sets the automatic gain control (AGC) to on or off. When AGC is enabled, 142 // 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 143 // the microphone volume is queried periodically and the volume level can
138 // be read in each AudioInputCallback::OnData() callback and fed to the 144 // be read in each AudioInputCallback::OnData() callback and fed to the
139 // render-side AGC. User must call StartAgc() as well to start measuring 145 // render-side AGC. User must call StartAgc() as well to start measuring
140 // the microphone level. 146 // the microphone level.
141 bool SetAutomaticGainControl(bool enabled) override { 147 bool SetAutomaticGainControl(bool enabled) override {
142 DVLOG(1) << "SetAutomaticGainControl(enabled=" << enabled << ")"; 148 DVLOG(1) << "SetAutomaticGainControl(enabled=" << enabled << ")";
143 DCHECK(thread_checker_.CalledOnValidThread()); 149 DCHECK(thread_checker_.CalledOnValidThread());
144 agc_is_enabled_ = enabled; 150 agc_is_enabled_ = enabled;
145 return true; 151 return true;
146 } 152 }
147 153
148 // Gets the current automatic gain control state.
149 bool GetAutomaticGainControl() override {
150 DCHECK(thread_checker_.CalledOnValidThread());
151 return agc_is_enabled_;
152 }
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
160 // thread and it leads to a more stable capture performance. 160 // thread and it leads to a more stable capture performance.
161 void QueryAndStoreNewMicrophoneVolume() { 161 void QueryAndStoreNewMicrophoneVolume() {
162 DCHECK(thread_checker_.CalledOnValidThread()); 162 DCHECK(thread_checker_.CalledOnValidThread());
163 163
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
OLDNEW
« no previous file with comments | « no previous file | media/audio/mac/audio_low_latency_input_mac.cc » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698