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 #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/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 const std::string& device_id) { | 256 const std::string& device_id) { |
257 DCHECK(task_runner_->BelongsToCurrentThread()); | 257 DCHECK(task_runner_->BelongsToCurrentThread()); |
258 | 258 |
259 #if defined(AUDIO_POWER_MONITORING) | 259 #if defined(AUDIO_POWER_MONITORING) |
260 // We only log silence state UMA stats for low latency mode and if we use a | 260 // We only log silence state UMA stats for low latency mode and if we use a |
261 // real device. | 261 // real device. |
262 if (params.format() != AudioParameters::AUDIO_FAKE) | 262 if (params.format() != AudioParameters::AUDIO_FAKE) |
263 log_silence_state_ = true; | 263 log_silence_state_ = true; |
264 #endif | 264 #endif |
265 | 265 |
266 low_latency_create_time_ = base::TimeTicks::Now(); | |
266 DoCreate(audio_manager, params, device_id); | 267 DoCreate(audio_manager, params, device_id); |
267 } | 268 } |
268 | 269 |
269 void AudioInputController::DoCreateForStream( | 270 void AudioInputController::DoCreateForStream( |
270 AudioInputStream* stream_to_control) { | 271 AudioInputStream* stream_to_control) { |
271 DCHECK(task_runner_->BelongsToCurrentThread()); | 272 DCHECK(task_runner_->BelongsToCurrentThread()); |
272 | 273 |
273 DCHECK(!stream_); | 274 DCHECK(!stream_); |
274 stream_ = stream_to_control; | 275 stream_ = stream_to_control; |
275 | 276 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 handler_->OnRecording(this); | 341 handler_->OnRecording(this); |
341 } | 342 } |
342 | 343 |
343 void AudioInputController::DoClose() { | 344 void AudioInputController::DoClose() { |
344 DCHECK(task_runner_->BelongsToCurrentThread()); | 345 DCHECK(task_runner_->BelongsToCurrentThread()); |
345 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CloseTime"); | 346 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CloseTime"); |
346 | 347 |
347 if (state_ == CLOSED) | 348 if (state_ == CLOSED) |
348 return; | 349 return; |
349 | 350 |
350 if (handler_) | 351 // If this is a low-latency stream, log the total duration (since DoCreate) |
351 handler_->OnLog(this, "AIC::DoClose"); | 352 // and add it to a UMA histogram. |
353 if (!low_latency_create_time_.is_null()) { | |
354 base::TimeDelta duration = | |
355 base::TimeTicks::Now() - low_latency_create_time_; | |
356 UMA_HISTOGRAM_LONG_TIMES("Media.InputStreamDuration", duration); | |
Henrik Grunell
2014/09/04 06:32:17
I think it should be called Media.AudioInputContro
henrika (OOO until Aug 14)
2014/09/04 12:27:37
Discussed off-line. Henrik G is OK with excluding
| |
357 if (handler_) { | |
358 std::ostringstream oss; | |
tommi (sloooow) - chröme
2014/09/03 13:50:03
use StringPrintf (stringstream should only be used
henrika (OOO until Aug 14)
2014/09/04 12:27:37
I tried to use it but was not able to come up with
henrika (OOO until Aug 14)
2014/09/04 12:54:13
Anyhow, fixed now ;-)
tommi (sloooow) - chröme
2014/09/04 16:53:21
It's because of the style guide. stringstream is
| |
359 oss << "AIC::DoClose: stream duration=" | |
360 << duration.InSeconds() << " seconds"; | |
361 handler_->OnLog(this, oss.str()); | |
362 } | |
363 } | |
352 | 364 |
353 // Delete the timer on the same thread that created it. | 365 // Delete the timer on the same thread that created it. |
354 no_data_timer_.reset(); | 366 no_data_timer_.reset(); |
355 | 367 |
356 DoStopCloseAndClearStream(); | 368 DoStopCloseAndClearStream(); |
357 SetDataIsActive(false); | 369 SetDataIsActive(false); |
358 | 370 |
359 if (SharedMemoryAndSyncSocketMode()) | 371 if (SharedMemoryAndSyncSocketMode()) |
360 sync_writer_->Close(); | 372 sync_writer_->Close(); |
361 | 373 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 } | 614 } |
603 | 615 |
604 void AudioInputController::LogSilenceState(SilenceState value) { | 616 void AudioInputController::LogSilenceState(SilenceState value) { |
605 UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerSessionSilenceReport", | 617 UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerSessionSilenceReport", |
606 value, | 618 value, |
607 SILENCE_STATE_MAX + 1); | 619 SILENCE_STATE_MAX + 1); |
608 } | 620 } |
609 #endif | 621 #endif |
610 | 622 |
611 } // namespace media | 623 } // namespace media |
OLD | NEW |