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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 virtual void Close() = 0; | 105 virtual void Close() = 0; |
106 }; | 106 }; |
107 | 107 |
108 // Factory method for creating an AudioOutputController. | 108 // Factory method for creating an AudioOutputController. |
109 // This also creates and opens an AudioOutputStream on the audio manager | 109 // This also creates and opens an AudioOutputStream on the audio manager |
110 // thread, and if this is successful, the |event_handler| will receive an | 110 // thread, and if this is successful, the |event_handler| will receive an |
111 // OnControllerCreated() call from the same audio manager thread. | 111 // OnControllerCreated() call from the same audio manager thread. |
112 // |audio_manager| must outlive AudioOutputController. | 112 // |audio_manager| must outlive AudioOutputController. |
113 // The |output_device_id| can be either empty (default device) or specify a | 113 // The |output_device_id| can be either empty (default device) or specify a |
114 // specific hardware device for audio output. | 114 // specific hardware device for audio output. |
115 static scoped_refptr<AudioOutputController> Create( | 115 static scoped_refptr<AudioOutputController> Create( |
Henrik Grunell
2016/12/16 14:12:59
Unless AudioInputDebugWriter (https://cs.chromium.
| |
116 AudioManager* audio_manager, EventHandler* event_handler, | 116 AudioManager* audio_manager, EventHandler* event_handler, |
117 const AudioParameters& params, const std::string& output_device_id, | 117 const AudioParameters& params, const std::string& output_device_id, |
118 SyncReader* sync_reader); | 118 SyncReader* sync_reader); |
119 | 119 |
120 // Indicates whether audio power level analysis will be performed. If false, | 120 // Indicates whether audio power level analysis will be performed. If false, |
121 // ReadCurrentPowerAndClip() can not be called. | 121 // ReadCurrentPowerAndClip() can not be called. |
122 static bool will_monitor_audio_levels() { | 122 static bool will_monitor_audio_levels() { |
123 #if defined(OS_ANDROID) || defined(OS_IOS) | 123 #if defined(OS_ANDROID) || defined(OS_IOS) |
124 return false; | 124 return false; |
125 #else | 125 #else |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 const AudioParameters& GetAudioParameters() override; | 182 const AudioParameters& GetAudioParameters() override; |
183 void StartDiverting(AudioOutputStream* to_stream) override; | 183 void StartDiverting(AudioOutputStream* to_stream) override; |
184 void StopDiverting() override; | 184 void StopDiverting() override; |
185 void StartDuplicating(AudioPushSink* sink) override; | 185 void StartDuplicating(AudioPushSink* sink) override; |
186 void StopDuplicating(AudioPushSink* sink) override; | 186 void StopDuplicating(AudioPushSink* sink) override; |
187 | 187 |
188 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in | 188 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in |
189 // audio_power_monitor.h for usage. This may be called on any thread. | 189 // audio_power_monitor.h for usage. This may be called on any thread. |
190 std::pair<float, bool> ReadCurrentPowerAndClip(); | 190 std::pair<float, bool> ReadCurrentPowerAndClip(); |
191 | 191 |
192 // Enable debug recording of audio. | |
193 void EnableDebugRecording(const base::FilePath& file_name); | |
194 | |
195 // Disable debug recording of audio. | |
196 void DisableDebugRecording(); | |
197 | |
192 protected: | 198 protected: |
193 // Internal state of the source. | 199 // Internal state of the source. |
194 enum State { | 200 enum State { |
195 kEmpty, | 201 kEmpty, |
196 kCreated, | 202 kCreated, |
197 kPlaying, | 203 kPlaying, |
198 kPaused, | 204 kPaused, |
199 kClosed, | 205 kClosed, |
200 kError, | 206 kError, |
201 }; | 207 }; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // Helper method that stops, closes, and NULLs |*stream_|. | 239 // Helper method that stops, closes, and NULLs |*stream_|. |
234 void DoStopCloseAndClearStream(); | 240 void DoStopCloseAndClearStream(); |
235 | 241 |
236 // Checks if a stream was started successfully but never calls OnMoreData(). | 242 // Checks if a stream was started successfully but never calls OnMoreData(). |
237 void WedgeCheck(); | 243 void WedgeCheck(); |
238 | 244 |
239 // Send audio data to each duplication target. | 245 // Send audio data to each duplication target. |
240 void BroadcastDataToDuplicationTargets(std::unique_ptr<AudioBus> audio_bus, | 246 void BroadcastDataToDuplicationTargets(std::unique_ptr<AudioBus> audio_bus, |
241 base::TimeTicks reference_time); | 247 base::TimeTicks reference_time); |
242 | 248 |
249 // Enable debug recording of audio. | |
250 void DoEnableDebugRecording(const base::FilePath& file_name); | |
251 | |
252 // Disable debug recording of audio. | |
253 void DoDisableDebugRecording(); | |
254 | |
243 AudioManager* const audio_manager_; | 255 AudioManager* const audio_manager_; |
244 const AudioParameters params_; | 256 const AudioParameters params_; |
245 EventHandler* const handler_; | 257 EventHandler* const handler_; |
246 | 258 |
247 // Specifies the device id of the output device to open or empty for the | 259 // Specifies the device id of the output device to open or empty for the |
248 // default output device. | 260 // default output device. |
249 std::string output_device_id_; | 261 std::string output_device_id_; |
250 | 262 |
251 AudioOutputStream* stream_; | 263 AudioOutputStream* stream_; |
252 | 264 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 // be accessed while |error_lock_| is held. | 297 // be accessed while |error_lock_| is held. |
286 bool ignore_errors_during_stop_close_; | 298 bool ignore_errors_during_stop_close_; |
287 base::Lock error_lock_; | 299 base::Lock error_lock_; |
288 | 300 |
289 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 301 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
290 }; | 302 }; |
291 | 303 |
292 } // namespace media | 304 } // namespace media |
293 | 305 |
294 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 306 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
OLD | NEW |