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

Side by Side Diff: media/audio/audio_input_controller.cc

Issue 14827002: Report timing statistics for audio controller methods via UMA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TimeTicks -> TimeDelta. Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/audio_output_controller.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 // 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 #include "media/audio/audio_input_controller.h" 5 #include "media/audio/audio_input_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/base/scoped_histogram_timer.h"
10 11
11 namespace { 12 namespace {
12 const int kMaxInputChannels = 2; 13 const int kMaxInputChannels = 2;
13 14
14 // TODO(henrika): remove usage of timers and add support for proper 15 // TODO(henrika): remove usage of timers and add support for proper
15 // notification of when the input device is removed. This was originally added 16 // notification of when the input device is removed. This was originally added
16 // to resolve http://crbug.com/79936 for Windows platforms. This then caused 17 // to resolve http://crbug.com/79936 for Windows platforms. This then caused
17 // breakage (very hard to repro bugs!) on other platforms: See 18 // breakage (very hard to repro bugs!) on other platforms: See
18 // http://crbug.com/226327 and http://crbug.com/230972. 19 // http://crbug.com/226327 and http://crbug.com/230972.
19 const int kTimerResetIntervalSeconds = 1; 20 const int kTimerResetIntervalSeconds = 1;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 162
162 void AudioInputController::SetAutomaticGainControl(bool enabled) { 163 void AudioInputController::SetAutomaticGainControl(bool enabled) {
163 message_loop_->PostTask(FROM_HERE, base::Bind( 164 message_loop_->PostTask(FROM_HERE, base::Bind(
164 &AudioInputController::DoSetAutomaticGainControl, this, enabled)); 165 &AudioInputController::DoSetAutomaticGainControl, this, enabled));
165 } 166 }
166 167
167 void AudioInputController::DoCreate(AudioManager* audio_manager, 168 void AudioInputController::DoCreate(AudioManager* audio_manager,
168 const AudioParameters& params, 169 const AudioParameters& params,
169 const std::string& device_id) { 170 const std::string& device_id) {
170 DCHECK(message_loop_->BelongsToCurrentThread()); 171 DCHECK(message_loop_->BelongsToCurrentThread());
172 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CreateTime");
171 // TODO(miu): See TODO at top of file. Until that's resolved, assume all 173 // TODO(miu): See TODO at top of file. Until that's resolved, assume all
172 // platform audio input requires the |no_data_timer_| be used to auto-detect 174 // platform audio input requires the |no_data_timer_| be used to auto-detect
173 // errors. In reality, probably only Windows and IOS need to be treated as 175 // errors. In reality, probably only Windows and IOS need to be treated as
174 // unreliable here. 176 // unreliable here.
175 DoCreateForStream(audio_manager->MakeAudioInputStream(params, device_id), 177 DoCreateForStream(audio_manager->MakeAudioInputStream(params, device_id),
176 true); 178 true);
177 } 179 }
178 180
179 void AudioInputController::DoCreateForStream( 181 void AudioInputController::DoCreateForStream(
180 AudioInputStream* stream_to_control, bool enable_nodata_timer) { 182 AudioInputStream* stream_to_control, bool enable_nodata_timer) {
(...skipping 26 matching lines...) Expand all
207 } else { 209 } else {
208 DVLOG(1) << "Disabled: timer check for no data."; 210 DVLOG(1) << "Disabled: timer check for no data.";
209 } 211 }
210 212
211 state_ = kCreated; 213 state_ = kCreated;
212 handler_->OnCreated(this); 214 handler_->OnCreated(this);
213 } 215 }
214 216
215 void AudioInputController::DoRecord() { 217 void AudioInputController::DoRecord() {
216 DCHECK(message_loop_->BelongsToCurrentThread()); 218 DCHECK(message_loop_->BelongsToCurrentThread());
219 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.RecordTime");
217 220
218 if (state_ != kCreated) 221 if (state_ != kCreated)
219 return; 222 return;
220 223
221 { 224 {
222 base::AutoLock auto_lock(lock_); 225 base::AutoLock auto_lock(lock_);
223 state_ = kRecording; 226 state_ = kRecording;
224 } 227 }
225 228
226 if (no_data_timer_) { 229 if (no_data_timer_) {
227 // Start the data timer. Once |kTimerResetIntervalSeconds| have passed, 230 // Start the data timer. Once |kTimerResetIntervalSeconds| have passed,
228 // a callback to DoCheckForNoData() is made. 231 // a callback to DoCheckForNoData() is made.
229 no_data_timer_->Reset(); 232 no_data_timer_->Reset();
230 } 233 }
231 234
232 stream_->Start(this); 235 stream_->Start(this);
233 handler_->OnRecording(this); 236 handler_->OnRecording(this);
234 } 237 }
235 238
236 void AudioInputController::DoClose() { 239 void AudioInputController::DoClose() {
237 DCHECK(message_loop_->BelongsToCurrentThread()); 240 DCHECK(message_loop_->BelongsToCurrentThread());
241 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CloseTime");
238 242
239 // Delete the timer on the same thread that created it. 243 // Delete the timer on the same thread that created it.
240 no_data_timer_.reset(); 244 no_data_timer_.reset();
241 245
242 if (state_ != kClosed) { 246 if (state_ != kClosed) {
243 DoStopCloseAndClearStream(NULL); 247 DoStopCloseAndClearStream(NULL);
244 SetDataIsActive(false); 248 SetDataIsActive(false);
245 249
246 if (LowLatencyMode()) { 250 if (LowLatencyMode()) {
247 sync_writer_->Close(); 251 sync_writer_->Close();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 372
369 void AudioInputController::SetDataIsActive(bool enabled) { 373 void AudioInputController::SetDataIsActive(bool enabled) {
370 base::subtle::Release_Store(&data_is_active_, enabled); 374 base::subtle::Release_Store(&data_is_active_, enabled);
371 } 375 }
372 376
373 bool AudioInputController::GetDataIsActive() { 377 bool AudioInputController::GetDataIsActive() {
374 return (base::subtle::Acquire_Load(&data_is_active_) != false); 378 return (base::subtle::Acquire_Load(&data_is_active_) != false);
375 } 379 }
376 380
377 } // namespace media 381 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_output_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698