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

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

Issue 537573002: Adding Media.InputStreamDuration to UMA histograms for low-latency input audio streams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now builds on all platforms Created 6 years, 3 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 | « media/audio/audio_input_controller.h ('k') | tools/metrics/histograms/histograms.xml » ('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/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
9 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "media/audio/audio_parameters.h" 12 #include "media/audio/audio_parameters.h"
12 #include "media/base/limits.h" 13 #include "media/base/limits.h"
13 #include "media/base/scoped_histogram_timer.h" 14 #include "media/base/scoped_histogram_timer.h"
14 #include "media/base/user_input_monitor.h" 15 #include "media/base/user_input_monitor.h"
15 16
16 using base::TimeDelta; 17 using base::TimeDelta;
17 18
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 const std::string& device_id) { 257 const std::string& device_id) {
257 DCHECK(task_runner_->BelongsToCurrentThread()); 258 DCHECK(task_runner_->BelongsToCurrentThread());
258 259
259 #if defined(AUDIO_POWER_MONITORING) 260 #if defined(AUDIO_POWER_MONITORING)
260 // We only log silence state UMA stats for low latency mode and if we use a 261 // We only log silence state UMA stats for low latency mode and if we use a
261 // real device. 262 // real device.
262 if (params.format() != AudioParameters::AUDIO_FAKE) 263 if (params.format() != AudioParameters::AUDIO_FAKE)
263 log_silence_state_ = true; 264 log_silence_state_ = true;
264 #endif 265 #endif
265 266
267 low_latency_create_time_ = base::TimeTicks::Now();
266 DoCreate(audio_manager, params, device_id); 268 DoCreate(audio_manager, params, device_id);
267 } 269 }
268 270
269 void AudioInputController::DoCreateForStream( 271 void AudioInputController::DoCreateForStream(
270 AudioInputStream* stream_to_control) { 272 AudioInputStream* stream_to_control) {
271 DCHECK(task_runner_->BelongsToCurrentThread()); 273 DCHECK(task_runner_->BelongsToCurrentThread());
272 274
273 DCHECK(!stream_); 275 DCHECK(!stream_);
274 stream_ = stream_to_control; 276 stream_ = stream_to_control;
275 277
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 handler_->OnRecording(this); 342 handler_->OnRecording(this);
341 } 343 }
342 344
343 void AudioInputController::DoClose() { 345 void AudioInputController::DoClose() {
344 DCHECK(task_runner_->BelongsToCurrentThread()); 346 DCHECK(task_runner_->BelongsToCurrentThread());
345 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CloseTime"); 347 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CloseTime");
346 348
347 if (state_ == CLOSED) 349 if (state_ == CLOSED)
348 return; 350 return;
349 351
350 if (handler_) 352 // If this is a low-latency stream, log the total duration (since DoCreate)
351 handler_->OnLog(this, "AIC::DoClose"); 353 // and add it to a UMA histogram.
354 if (!low_latency_create_time_.is_null()) {
355 base::TimeDelta duration =
356 base::TimeTicks::Now() - low_latency_create_time_;
357 UMA_HISTOGRAM_LONG_TIMES("Media.InputStreamDuration", duration);
358 if (handler_) {
359 std::string log_string =
360 base::StringPrintf("AIC::DoClose: stream duration=");
361 log_string += base::Int64ToString(duration.InSeconds());
362 log_string += " seconds";
363 handler_->OnLog(this, log_string);
364 }
365 }
352 366
353 // Delete the timer on the same thread that created it. 367 // Delete the timer on the same thread that created it.
354 no_data_timer_.reset(); 368 no_data_timer_.reset();
355 369
356 DoStopCloseAndClearStream(); 370 DoStopCloseAndClearStream();
357 SetDataIsActive(false); 371 SetDataIsActive(false);
358 372
359 if (SharedMemoryAndSyncSocketMode()) 373 if (SharedMemoryAndSyncSocketMode())
360 sync_writer_->Close(); 374 sync_writer_->Close();
361 375
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 } 616 }
603 617
604 void AudioInputController::LogSilenceState(SilenceState value) { 618 void AudioInputController::LogSilenceState(SilenceState value) {
605 UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerSessionSilenceReport", 619 UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerSessionSilenceReport",
606 value, 620 value,
607 SILENCE_STATE_MAX + 1); 621 SILENCE_STATE_MAX + 1);
608 } 622 }
609 #endif 623 #endif
610 624
611 } // namespace media 625 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698