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 <stdint.h> | 8 #include <stdint.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // SyncReader) must exist until closed_task is called, but they are safe | 141 // SyncReader) must exist until closed_task is called, but they are safe |
142 // to delete after that. | 142 // to delete after that. |
143 // | 143 // |
144 // It is safe to call this method more than once. Calls after the first one | 144 // It is safe to call this method more than once. Calls after the first one |
145 // will have no effect. | 145 // will have no effect. |
146 void Close(const base::Closure& closed_task); | 146 void Close(const base::Closure& closed_task); |
147 | 147 |
148 // Sets the volume of the audio output stream. | 148 // Sets the volume of the audio output stream. |
149 void SetVolume(double volume); | 149 void SetVolume(double volume); |
150 | 150 |
151 // Calls |callback| (on the caller's thread) with the current output | |
152 // device ID. | |
153 void GetOutputDeviceId( | |
154 base::Callback<void(const std::string&)> callback) const; | |
155 | |
156 // Changes which output device to use. If desired, you can provide a | |
157 // callback that will be notified (on the thread you called from) | |
158 // when the function has completed execution. | |
159 // | |
160 // Changing the output device causes the controller to go through | |
161 // the same state transition back to the current state as a call to | |
162 // OnDeviceChange (unless it is currently diverting, see | |
163 // Start/StopDiverting below, in which case the state transition | |
164 // will happen when StopDiverting is called). | |
165 void SwitchOutputDevice(const std::string& output_device_id, | |
166 const base::Closure& callback); | |
167 | |
168 // AudioSourceCallback implementation. | 151 // AudioSourceCallback implementation. |
169 int OnMoreData(base::TimeDelta delay, | 152 int OnMoreData(base::TimeDelta delay, |
170 base::TimeTicks delay_timestamp, | 153 base::TimeTicks delay_timestamp, |
171 int prior_frames_skipped, | 154 int prior_frames_skipped, |
172 AudioBus* dest) override; | 155 AudioBus* dest) override; |
173 void OnError(AudioOutputStream* stream) override; | 156 void OnError(AudioOutputStream* stream) override; |
174 | 157 |
175 // AudioDeviceListener implementation. When called AudioOutputController will | 158 // AudioDeviceListener implementation. When called AudioOutputController will |
176 // shutdown the existing |stream_|, transition to the kRecreating state, | 159 // shutdown the existing |stream_|, transition to the kRecreating state, |
177 // create a new stream, and then transition back to an equivalent state prior | 160 // create a new stream, and then transition back to an equivalent state prior |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 const AudioParameters& params, | 195 const AudioParameters& params, |
213 const std::string& output_device_id, | 196 const std::string& output_device_id, |
214 SyncReader* sync_reader); | 197 SyncReader* sync_reader); |
215 | 198 |
216 // The following methods are executed on the audio manager thread. | 199 // The following methods are executed on the audio manager thread. |
217 void DoCreate(bool is_for_device_change); | 200 void DoCreate(bool is_for_device_change); |
218 void DoPlay(); | 201 void DoPlay(); |
219 void DoPause(); | 202 void DoPause(); |
220 void DoClose(); | 203 void DoClose(); |
221 void DoSetVolume(double volume); | 204 void DoSetVolume(double volume); |
222 std::string DoGetOutputDeviceId() const; | |
223 void DoSwitchOutputDevice(const std::string& output_device_id); | |
224 void DoReportError(); | 205 void DoReportError(); |
225 void DoStartDiverting(AudioOutputStream* to_stream); | 206 void DoStartDiverting(AudioOutputStream* to_stream); |
226 void DoStopDiverting(); | 207 void DoStopDiverting(); |
227 void DoStartDuplicating(AudioPushSink* sink); | 208 void DoStartDuplicating(AudioPushSink* sink); |
228 void DoStopDuplicating(AudioPushSink* sink); | 209 void DoStopDuplicating(AudioPushSink* sink); |
229 | 210 |
230 // Helper method that stops the physical stream. | 211 // Helper method that stops the physical stream. |
231 void StopStream(); | 212 void StopStream(); |
232 | 213 |
233 // Helper method that stops, closes, and NULLs |*stream_|. | 214 // Helper method that stops, closes, and NULLs |*stream_|. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // be accessed while |error_lock_| is held. | 266 // be accessed while |error_lock_| is held. |
286 bool ignore_errors_during_stop_close_; | 267 bool ignore_errors_during_stop_close_; |
287 base::Lock error_lock_; | 268 base::Lock error_lock_; |
288 | 269 |
289 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 270 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
290 }; | 271 }; |
291 | 272 |
292 } // namespace media | 273 } // namespace media |
293 | 274 |
294 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 275 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
OLD | NEW |