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 #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" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 virtual int Read(bool block, const AudioBus* source, AudioBus* dest) = 0; | 93 virtual int Read(bool block, const AudioBus* source, AudioBus* dest) = 0; |
| 94 | 94 |
| 95 // Close this synchronous reader. | 95 // Close this synchronous reader. |
| 96 virtual void Close() = 0; | 96 virtual void Close() = 0; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 // Factory method for creating an AudioOutputController. | 99 // Factory method for creating an AudioOutputController. |
| 100 // This also creates and opens an AudioOutputStream on the audio manager | 100 // This also creates and opens an AudioOutputStream on the audio manager |
| 101 // thread, and if this is successful, the |event_handler| will receive an | 101 // thread, and if this is successful, the |event_handler| will receive an |
| 102 // OnCreated() call from the same audio manager thread. |audio_manager| must | 102 // OnCreated() call from the same audio manager thread. |audio_manager| must |
| 103 // outlive AudioOutputController. | 103 // outlive AudioOutputController. |
|
henrika (OOO until Aug 14)
2013/09/06 08:44:38
Should we extend the comment and mention device ID
tommi (sloooow) - chröme
2013/09/06 11:01:35
Done.
| |
| 104 static scoped_refptr<AudioOutputController> Create( | 104 static scoped_refptr<AudioOutputController> Create( |
| 105 AudioManager* audio_manager, EventHandler* event_handler, | 105 AudioManager* audio_manager, EventHandler* event_handler, |
| 106 const AudioParameters& params, const std::string& input_device_id, | 106 const AudioParameters& params, const std::string& output_device_id, |
| 107 SyncReader* sync_reader); | 107 const std::string& input_device_id, SyncReader* sync_reader); |
| 108 | 108 |
| 109 // Methods to control playback of the stream. | 109 // Methods to control playback of the stream. |
| 110 | 110 |
| 111 // Starts the playback of this audio output stream. | 111 // Starts the playback of this audio output stream. |
| 112 void Play(); | 112 void Play(); |
| 113 | 113 |
| 114 // Pause this audio output stream. | 114 // Pause this audio output stream. |
| 115 void Pause(); | 115 void Pause(); |
| 116 | 116 |
| 117 // Closes the audio output stream. The state is changed and the resources | 117 // Closes the audio output stream. The state is changed and the resources |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 friend class base::RefCountedThreadSafe<AudioOutputController>; | 159 friend class base::RefCountedThreadSafe<AudioOutputController>; |
| 160 virtual ~AudioOutputController(); | 160 virtual ~AudioOutputController(); |
| 161 | 161 |
| 162 private: | 162 private: |
| 163 // We are polling sync reader if data became available. | 163 // We are polling sync reader if data became available. |
| 164 static const int kPollNumAttempts; | 164 static const int kPollNumAttempts; |
| 165 static const int kPollPauseInMilliseconds; | 165 static const int kPollPauseInMilliseconds; |
| 166 | 166 |
| 167 AudioOutputController(AudioManager* audio_manager, EventHandler* handler, | 167 AudioOutputController(AudioManager* audio_manager, EventHandler* handler, |
| 168 const AudioParameters& params, | 168 const AudioParameters& params, |
| 169 const std::string& output_device_id, | |
| 169 const std::string& input_device_id, | 170 const std::string& input_device_id, |
| 170 SyncReader* sync_reader); | 171 SyncReader* sync_reader); |
| 171 | 172 |
| 172 // The following methods are executed on the audio manager thread. | 173 // The following methods are executed on the audio manager thread. |
| 173 void DoCreate(bool is_for_device_change); | 174 void DoCreate(bool is_for_device_change); |
| 174 void DoPlay(); | 175 void DoPlay(); |
| 175 void DoPause(); | 176 void DoPause(); |
| 176 void DoClose(); | 177 void DoClose(); |
| 177 void DoSetVolume(double volume); | 178 void DoSetVolume(double volume); |
| 178 void DoReportError(); | 179 void DoReportError(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 191 | 192 |
| 192 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread | 193 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread |
| 193 // happens only between AudioOutputStream::Start() and Stop(). | 194 // happens only between AudioOutputStream::Start() and Stop(). |
| 194 void AllowEntryToOnMoreIOData(); | 195 void AllowEntryToOnMoreIOData(); |
| 195 void DisallowEntryToOnMoreIOData(); | 196 void DisallowEntryToOnMoreIOData(); |
| 196 | 197 |
| 197 AudioManager* const audio_manager_; | 198 AudioManager* const audio_manager_; |
| 198 const AudioParameters params_; | 199 const AudioParameters params_; |
| 199 EventHandler* const handler_; | 200 EventHandler* const handler_; |
| 200 | 201 |
| 202 // Specified the device id of the output device to open or empty for the | |
|
henrika (OOO until Aug 14)
2013/09/06 08:44:38
Specified the device id of... sounds odd to me. Di
tommi (sloooow) - chröme
2013/09/06 11:01:35
Yes, thanks, fixed.
| |
| 203 // default output device. | |
| 204 const std::string output_device_id_; | |
| 205 | |
| 201 // Used by the unified IO to open the correct input device. | 206 // Used by the unified IO to open the correct input device. |
| 202 std::string input_device_id_; | 207 const std::string input_device_id_; |
| 203 | 208 |
| 204 AudioOutputStream* stream_; | 209 AudioOutputStream* stream_; |
| 205 | 210 |
| 206 // When non-NULL, audio is being diverted to this stream. | 211 // When non-NULL, audio is being diverted to this stream. |
| 207 AudioOutputStream* diverting_to_stream_; | 212 AudioOutputStream* diverting_to_stream_; |
| 208 | 213 |
| 209 // The current volume of the audio stream. | 214 // The current volume of the audio stream. |
| 210 double volume_; | 215 double volume_; |
| 211 | 216 |
| 212 // |state_| is written on the audio manager thread and is read on the | 217 // |state_| is written on the audio manager thread and is read on the |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 236 | 241 |
| 237 // Periodic callback to report power levels during playback. | 242 // Periodic callback to report power levels during playback. |
| 238 base::CancelableClosure power_poll_callback_; | 243 base::CancelableClosure power_poll_callback_; |
| 239 | 244 |
| 240 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 245 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 241 }; | 246 }; |
| 242 | 247 |
| 243 } // namespace media | 248 } // namespace media |
| 244 | 249 |
| 245 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 250 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |