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 | |
10 #include <memory> | 9 #include <memory> |
| 10 #include <set> |
11 | 11 |
12 #include "base/atomic_ref_count.h" | 12 #include "base/atomic_ref_count.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "media/audio/audio_io.h" | 19 #include "media/audio/audio_io.h" |
20 #include "media/audio/audio_manager.h" | 20 #include "media/audio/audio_manager.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // AudioDeviceListener implementation. When called AudioOutputController will | 171 // AudioDeviceListener implementation. When called AudioOutputController will |
172 // shutdown the existing |stream_|, transition to the kRecreating state, | 172 // shutdown the existing |stream_|, transition to the kRecreating state, |
173 // create a new stream, and then transition back to an equivalent state prior | 173 // create a new stream, and then transition back to an equivalent state prior |
174 // to being called. | 174 // to being called. |
175 void OnDeviceChange() override; | 175 void OnDeviceChange() override; |
176 | 176 |
177 // AudioSourceDiverter implementation. | 177 // AudioSourceDiverter implementation. |
178 const AudioParameters& GetAudioParameters() override; | 178 const AudioParameters& GetAudioParameters() override; |
179 void StartDiverting(AudioOutputStream* to_stream) override; | 179 void StartDiverting(AudioOutputStream* to_stream) override; |
180 void StopDiverting() override; | 180 void StopDiverting() override; |
| 181 void StartDuplicating(AudioPushSink* sink) override; |
| 182 void StopDuplicating(AudioPushSink* sink) override; |
181 | 183 |
182 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in | 184 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in |
183 // audio_power_monitor.h for usage. This may be called on any thread. | 185 // audio_power_monitor.h for usage. This may be called on any thread. |
184 std::pair<float, bool> ReadCurrentPowerAndClip(); | 186 std::pair<float, bool> ReadCurrentPowerAndClip(); |
185 | 187 |
186 protected: | 188 protected: |
187 // Internal state of the source. | 189 // Internal state of the source. |
188 enum State { | 190 enum State { |
189 kEmpty, | 191 kEmpty, |
190 kCreated, | 192 kCreated, |
(...skipping 20 matching lines...) Expand all Loading... |
211 void DoCreate(bool is_for_device_change); | 213 void DoCreate(bool is_for_device_change); |
212 void DoPlay(); | 214 void DoPlay(); |
213 void DoPause(); | 215 void DoPause(); |
214 void DoClose(); | 216 void DoClose(); |
215 void DoSetVolume(double volume); | 217 void DoSetVolume(double volume); |
216 std::string DoGetOutputDeviceId() const; | 218 std::string DoGetOutputDeviceId() const; |
217 void DoSwitchOutputDevice(const std::string& output_device_id); | 219 void DoSwitchOutputDevice(const std::string& output_device_id); |
218 void DoReportError(); | 220 void DoReportError(); |
219 void DoStartDiverting(AudioOutputStream* to_stream); | 221 void DoStartDiverting(AudioOutputStream* to_stream); |
220 void DoStopDiverting(); | 222 void DoStopDiverting(); |
| 223 void DoStartDuplicating(AudioPushSink* sink); |
| 224 void DoStopDuplicating(AudioPushSink* sink); |
221 | 225 |
222 // Helper method that stops the physical stream. | 226 // Helper method that stops the physical stream. |
223 void StopStream(); | 227 void StopStream(); |
224 | 228 |
225 // Helper method that stops, closes, and NULLs |*stream_|. | 229 // Helper method that stops, closes, and NULLs |*stream_|. |
226 void DoStopCloseAndClearStream(); | 230 void DoStopCloseAndClearStream(); |
227 | 231 |
228 // Checks if a stream was started successfully but never calls OnMoreData(). | 232 // Checks if a stream was started successfully but never calls OnMoreData(). |
229 void WedgeCheck(); | 233 void WedgeCheck(); |
230 | 234 |
231 AudioManager* const audio_manager_; | 235 AudioManager* const audio_manager_; |
232 const AudioParameters params_; | 236 const AudioParameters params_; |
233 EventHandler* const handler_; | 237 EventHandler* const handler_; |
234 | 238 |
235 // Specifies the device id of the output device to open or empty for the | 239 // Specifies the device id of the output device to open or empty for the |
236 // default output device. | 240 // default output device. |
237 std::string output_device_id_; | 241 std::string output_device_id_; |
238 | 242 |
239 AudioOutputStream* stream_; | 243 AudioOutputStream* stream_; |
240 | 244 |
241 // When non-NULL, audio is being diverted to this stream. | 245 // When non-NULL, audio is being diverted to this stream. |
242 AudioOutputStream* diverting_to_stream_; | 246 AudioOutputStream* diverting_to_stream_; |
243 | 247 |
| 248 // The targets for audio stream to be copied to. |
| 249 std::set<AudioPushSink*> duplication_targets_; |
| 250 base::Lock duplication_targets_lock_; |
| 251 |
244 // The current volume of the audio stream. | 252 // The current volume of the audio stream. |
245 double volume_; | 253 double volume_; |
246 | 254 |
247 // |state_| may only be used on the audio manager thread. | 255 // |state_| may only be used on the audio manager thread. |
248 State state_; | 256 State state_; |
249 | 257 |
250 // SyncReader is used only in low latency mode for synchronous reading. | 258 // SyncReader is used only in low latency mode for synchronous reading. |
251 SyncReader* const sync_reader_; | 259 SyncReader* const sync_reader_; |
252 | 260 |
253 // The message loop of audio manager thread that this object runs on. | 261 // The message loop of audio manager thread that this object runs on. |
(...skipping 15 matching lines...) Expand all Loading... |
269 // be accessed while |error_lock_| is held. | 277 // be accessed while |error_lock_| is held. |
270 bool ignore_errors_during_stop_close_; | 278 bool ignore_errors_during_stop_close_; |
271 base::Lock error_lock_; | 279 base::Lock error_lock_; |
272 | 280 |
273 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 281 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
274 }; | 282 }; |
275 | 283 |
276 } // namespace media | 284 } // namespace media |
277 | 285 |
278 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 286 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
OLD | NEW |