| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. |
| 104 // The |output_device_id| can be either empty (default device) or specify a |
| 105 // specific hardware device for audio output. The |input_device_id| is |
| 106 // used only for unified audio when opening up input and output at the same |
| 107 // time (controlled by |params.input_channel_count()|). |
| 104 static scoped_refptr<AudioOutputController> Create( | 108 static scoped_refptr<AudioOutputController> Create( |
| 105 AudioManager* audio_manager, EventHandler* event_handler, | 109 AudioManager* audio_manager, EventHandler* event_handler, |
| 106 const AudioParameters& params, const std::string& input_device_id, | 110 const AudioParameters& params, const std::string& output_device_id, |
| 107 SyncReader* sync_reader); | 111 const std::string& input_device_id, SyncReader* sync_reader); |
| 108 | 112 |
| 109 // Methods to control playback of the stream. | 113 // Methods to control playback of the stream. |
| 110 | 114 |
| 111 // Starts the playback of this audio output stream. | 115 // Starts the playback of this audio output stream. |
| 112 void Play(); | 116 void Play(); |
| 113 | 117 |
| 114 // Pause this audio output stream. | 118 // Pause this audio output stream. |
| 115 void Pause(); | 119 void Pause(); |
| 116 | 120 |
| 117 // Closes the audio output stream. The state is changed and the resources | 121 // 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>; | 163 friend class base::RefCountedThreadSafe<AudioOutputController>; |
| 160 virtual ~AudioOutputController(); | 164 virtual ~AudioOutputController(); |
| 161 | 165 |
| 162 private: | 166 private: |
| 163 // We are polling sync reader if data became available. | 167 // We are polling sync reader if data became available. |
| 164 static const int kPollNumAttempts; | 168 static const int kPollNumAttempts; |
| 165 static const int kPollPauseInMilliseconds; | 169 static const int kPollPauseInMilliseconds; |
| 166 | 170 |
| 167 AudioOutputController(AudioManager* audio_manager, EventHandler* handler, | 171 AudioOutputController(AudioManager* audio_manager, EventHandler* handler, |
| 168 const AudioParameters& params, | 172 const AudioParameters& params, |
| 173 const std::string& output_device_id, |
| 169 const std::string& input_device_id, | 174 const std::string& input_device_id, |
| 170 SyncReader* sync_reader); | 175 SyncReader* sync_reader); |
| 171 | 176 |
| 172 // The following methods are executed on the audio manager thread. | 177 // The following methods are executed on the audio manager thread. |
| 173 void DoCreate(bool is_for_device_change); | 178 void DoCreate(bool is_for_device_change); |
| 174 void DoPlay(); | 179 void DoPlay(); |
| 175 void DoPause(); | 180 void DoPause(); |
| 176 void DoClose(); | 181 void DoClose(); |
| 177 void DoSetVolume(double volume); | 182 void DoSetVolume(double volume); |
| 178 void DoReportError(); | 183 void DoReportError(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 191 | 196 |
| 192 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread | 197 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread |
| 193 // happens only between AudioOutputStream::Start() and Stop(). | 198 // happens only between AudioOutputStream::Start() and Stop(). |
| 194 void AllowEntryToOnMoreIOData(); | 199 void AllowEntryToOnMoreIOData(); |
| 195 void DisallowEntryToOnMoreIOData(); | 200 void DisallowEntryToOnMoreIOData(); |
| 196 | 201 |
| 197 AudioManager* const audio_manager_; | 202 AudioManager* const audio_manager_; |
| 198 const AudioParameters params_; | 203 const AudioParameters params_; |
| 199 EventHandler* const handler_; | 204 EventHandler* const handler_; |
| 200 | 205 |
| 206 // Specifies the device id of the output device to open or empty for the |
| 207 // default output device. |
| 208 const std::string output_device_id_; |
| 209 |
| 201 // Used by the unified IO to open the correct input device. | 210 // Used by the unified IO to open the correct input device. |
| 202 std::string input_device_id_; | 211 const std::string input_device_id_; |
| 203 | 212 |
| 204 AudioOutputStream* stream_; | 213 AudioOutputStream* stream_; |
| 205 | 214 |
| 206 // When non-NULL, audio is being diverted to this stream. | 215 // When non-NULL, audio is being diverted to this stream. |
| 207 AudioOutputStream* diverting_to_stream_; | 216 AudioOutputStream* diverting_to_stream_; |
| 208 | 217 |
| 209 // The current volume of the audio stream. | 218 // The current volume of the audio stream. |
| 210 double volume_; | 219 double volume_; |
| 211 | 220 |
| 212 // |state_| is written on the audio manager thread and is read on the | 221 // |state_| is written on the audio manager thread and is read on the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 236 | 245 |
| 237 // Periodic callback to report power levels during playback. | 246 // Periodic callback to report power levels during playback. |
| 238 base::CancelableClosure power_poll_callback_; | 247 base::CancelableClosure power_poll_callback_; |
| 239 | 248 |
| 240 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 249 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 241 }; | 250 }; |
| 242 | 251 |
| 243 } // namespace media | 252 } // namespace media |
| 244 | 253 |
| 245 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 254 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |