| 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 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/atomic_ref_count.h" | 8 #include "base/atomic_ref_count.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/timer/timer.h" |
| 12 #include "media/audio/audio_io.h" | 13 #include "media/audio/audio_io.h" |
| 13 #include "media/audio/audio_manager.h" | 14 #include "media/audio/audio_manager.h" |
| 14 #include "media/audio/audio_power_monitor.h" | 15 #include "media/audio/audio_power_monitor.h" |
| 15 #include "media/audio/audio_source_diverter.h" | 16 #include "media/audio/audio_source_diverter.h" |
| 16 #include "media/audio/simple_sources.h" | 17 #include "media/audio/simple_sources.h" |
| 17 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
| 18 | 19 |
| 19 // An AudioOutputController controls an AudioOutputStream and provides data | 20 // An AudioOutputController controls an AudioOutputStream and provides data |
| 20 // to this output stream. It has an important function that it executes | 21 // to this output stream. It has an important function that it executes |
| 21 // audio operations like play, pause, stop, etc. on a separate thread, | 22 // audio operations like play, pause, stop, etc. on a separate thread, |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void StopStream(); | 216 void StopStream(); |
| 216 | 217 |
| 217 // Helper method that stops, closes, and NULLs |*stream_|. | 218 // Helper method that stops, closes, and NULLs |*stream_|. |
| 218 void DoStopCloseAndClearStream(); | 219 void DoStopCloseAndClearStream(); |
| 219 | 220 |
| 220 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread | 221 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread |
| 221 // happens only between AudioOutputStream::Start() and Stop(). | 222 // happens only between AudioOutputStream::Start() and Stop(). |
| 222 void AllowEntryToOnMoreIOData(); | 223 void AllowEntryToOnMoreIOData(); |
| 223 void DisallowEntryToOnMoreIOData(); | 224 void DisallowEntryToOnMoreIOData(); |
| 224 | 225 |
| 226 // Checks if a stream was started successfully but never calls OnMoreIOData(). |
| 227 void WedgeCheck(); |
| 228 |
| 225 AudioManager* const audio_manager_; | 229 AudioManager* const audio_manager_; |
| 226 const AudioParameters params_; | 230 const AudioParameters params_; |
| 227 EventHandler* const handler_; | 231 EventHandler* const handler_; |
| 228 | 232 |
| 229 // Specifies the device id of the output device to open or empty for the | 233 // Specifies the device id of the output device to open or empty for the |
| 230 // default output device. | 234 // default output device. |
| 231 std::string output_device_id_; | 235 std::string output_device_id_; |
| 232 | 236 |
| 233 // Used by the unified IO to open the correct input device. | 237 // Used by the unified IO to open the correct input device. |
| 234 const std::string input_device_id_; | 238 const std::string input_device_id_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 260 const scoped_refptr<base::MessageLoopProxy> message_loop_; | 264 const scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 261 | 265 |
| 262 #if defined(AUDIO_POWER_MONITORING) | 266 #if defined(AUDIO_POWER_MONITORING) |
| 263 // Scans audio samples from OnMoreIOData() as input to compute power levels. | 267 // Scans audio samples from OnMoreIOData() as input to compute power levels. |
| 264 AudioPowerMonitor power_monitor_; | 268 AudioPowerMonitor power_monitor_; |
| 265 | 269 |
| 266 // Periodic callback to report power levels during playback. | 270 // Periodic callback to report power levels during playback. |
| 267 base::CancelableClosure power_poll_callback_; | 271 base::CancelableClosure power_poll_callback_; |
| 268 #endif | 272 #endif |
| 269 | 273 |
| 270 // When starting stream we wait for data to become available. | 274 // Flags when we've asked for a stream to start but it never did. |
| 271 // Number of times left. | 275 bool wedge_detected_; |
| 272 int number_polling_attempts_left_; | 276 base::OneShotTimer<AudioOutputController> wedge_timer_; |
| 273 | 277 |
| 274 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 278 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 275 }; | 279 }; |
| 276 | 280 |
| 277 } // namespace media | 281 } // namespace media |
| 278 | 282 |
| 279 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 283 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |