Chromium Code Reviews| 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_output_controller.h" | 5 #include "media/audio/audio_output_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 #if defined(AUDIO_POWER_MONITORING) | 191 #if defined(AUDIO_POWER_MONITORING) |
| 192 power_monitor_.Reset(); | 192 power_monitor_.Reset(); |
| 193 power_poll_callback_.Reset( | 193 power_poll_callback_.Reset( |
| 194 base::Bind(&AudioOutputController::ReportPowerMeasurementPeriodically, | 194 base::Bind(&AudioOutputController::ReportPowerMeasurementPeriodically, |
| 195 this)); | 195 this)); |
| 196 // Run the callback to send an initial notification that we're starting in | 196 // Run the callback to send an initial notification that we're starting in |
| 197 // silence, and to schedule periodic callbacks. | 197 // silence, and to schedule periodic callbacks. |
| 198 power_poll_callback_.callback().Run(); | 198 power_poll_callback_.callback().Run(); |
| 199 #endif | 199 #endif |
| 200 | 200 |
| 201 AllowEntryToOnMoreIOData(); | |
| 202 stream_->Start(this); | |
| 203 | |
| 201 // For UMA tracking purposes, start the wedge detection timer. This allows us | 204 // For UMA tracking purposes, start the wedge detection timer. This allows us |
| 202 // to record statistics about the number of wedged playbacks in the field. | 205 // to record statistics about the number of wedged playbacks in the field. |
| 203 // | 206 // |
| 204 // WedgeCheck() will look to see if |on_more_io_data_called_| is true after | 207 // WedgeCheck() will look to see if |on_more_io_data_called_| is true after |
| 205 // the timeout expires. Care must be taken to ensure the wedge check delay is | 208 // the timeout expires. Care must be taken to ensure the wedge check delay is |
| 206 // large enough that the value isn't queried while OnMoreDataIO() is setting | 209 // large enough that the value isn't queried while OnMoreDataIO() is setting |
| 207 // it. | 210 // it. |
| 208 // | 211 // |
| 209 // Timer self-manages its lifetime and WedgeCheck() will only record the UMA | 212 // Timer self-manages its lifetime and WedgeCheck() will only record the UMA |
| 210 // statistic if state is still kPlaying. Additional Start() calls will | 213 // statistic if state is still kPlaying. Additional Start() calls will |
| 211 // invalidate the previous timer. | 214 // invalidate the previous timer. |
| 212 wedge_timer_.reset(new base::OneShotTimer<AudioOutputController>()); | 215 wedge_timer_.reset(new base::OneShotTimer<AudioOutputController>()); |
| 213 wedge_timer_->Start( | 216 wedge_timer_->Start( |
| 214 FROM_HERE, TimeDelta::FromSeconds(3), this, | 217 FROM_HERE, TimeDelta::FromSeconds(3), this, |
| 215 &AudioOutputController::WedgeCheck); | 218 &AudioOutputController::WedgeCheck); |
| 216 on_more_io_data_called_ = 0; | 219 on_more_io_data_called_ = 0; |
|
miu
2013/11/07 23:18:41
Should this statement (setting on_more_io_data_cal
DaleCurtis
2013/11/07 23:22:54
Good catch!
| |
| 217 | 220 |
| 218 AllowEntryToOnMoreIOData(); | |
| 219 stream_->Start(this); | |
| 220 | |
| 221 handler_->OnPlaying(); | 221 handler_->OnPlaying(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 #if defined(AUDIO_POWER_MONITORING) | 224 #if defined(AUDIO_POWER_MONITORING) |
| 225 void AudioOutputController::ReportPowerMeasurementPeriodically() { | 225 void AudioOutputController::ReportPowerMeasurementPeriodically() { |
| 226 DCHECK(message_loop_->BelongsToCurrentThread()); | 226 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 227 const std::pair<float, bool>& reading = | 227 const std::pair<float, bool>& reading = |
| 228 power_monitor_.ReadCurrentPowerAndClip(); | 228 power_monitor_.ReadCurrentPowerAndClip(); |
| 229 handler_->OnPowerMeasured(reading.first, reading.second); | 229 handler_->OnPowerMeasured(reading.first, reading.second); |
| 230 message_loop_->PostDelayedTask( | 230 message_loop_->PostDelayedTask( |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 if (state_ == kPlaying) { | 477 if (state_ == kPlaying) { |
| 478 UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputControllerPlaybackStartupSuccess", | 478 UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputControllerPlaybackStartupSuccess", |
| 479 base::AtomicRefCountIsOne(&on_more_io_data_called_)); | 479 base::AtomicRefCountIsOne(&on_more_io_data_called_)); |
| 480 | 480 |
| 481 // TODO(dalecurtis): Temporary debugging measure for http://crbug.com/160920 | 481 // TODO(dalecurtis): Temporary debugging measure for http://crbug.com/160920 |
| 482 CHECK(base::AtomicRefCountIsOne(&on_more_io_data_called_)); | 482 CHECK(base::AtomicRefCountIsOne(&on_more_io_data_called_)); |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace media | 486 } // namespace media |
| OLD | NEW |