| 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_MANAGER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_ | 6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "media/audio/audio_device_description.h" | 17 #include "media/audio/audio_device_description.h" |
| 18 #include "media/audio/audio_file_writer.h" |
| 18 #include "media/audio/audio_logging.h" | 19 #include "media/audio/audio_logging.h" |
| 19 #include "media/base/audio_parameters.h" | 20 #include "media/base/audio_parameters.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace media { | 26 namespace media { |
| 26 | 27 |
| 27 class AudioInputStream; | 28 class AudioInputStream; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 56 // main thread of the process, which in our case is sadly the browser UI | 57 // main thread of the process, which in our case is sadly the browser UI |
| 57 // thread. Failure to execute calls on the right thread leads to crashes and | 58 // thread. Failure to execute calls on the right thread leads to crashes and |
| 58 // odd behavior. See http://crbug.com/158170. | 59 // odd behavior. See http://crbug.com/158170. |
| 59 // | 60 // |
| 60 // The manager will use |worker_task_runner| for heavyweight tasks. | 61 // The manager will use |worker_task_runner| for heavyweight tasks. |
| 61 // The |worker_task_runner| may be the same as |task_runner|. This same | 62 // The |worker_task_runner| may be the same as |task_runner|. This same |
| 62 // task runner is returned by GetWorkerTaskRunner. | 63 // task runner is returned by GetWorkerTaskRunner. |
| 63 static ScopedAudioManagerPtr Create( | 64 static ScopedAudioManagerPtr Create( |
| 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 65 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 65 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 66 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
| 66 AudioLogFactory* audio_log_factory); | 67 AudioLogFactory* audio_log_factory, |
| 68 CreateAudioFileWriterCallback create_audio_file_writer_callback); |
| 67 | 69 |
| 68 // A convenience wrapper of AudioManager::Create for testing. | 70 // A convenience wrapper of AudioManager::Create for testing. |
| 69 // The given |task_runner| is shared for both audio io and heavyweight tasks. | 71 // The given |task_runner| is shared for both audio io and heavyweight tasks. |
| 70 static ScopedAudioManagerPtr CreateForTesting( | 72 static ScopedAudioManagerPtr CreateForTesting( |
| 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 73 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 72 | 74 |
| 73 // Starts monitoring AudioManager task runner for hangs. | 75 // Starts monitoring AudioManager task runner for hangs. |
| 74 // Runs the monitor on the given |task_runner|, which must be different from | 76 // Runs the monitor on the given |task_runner|, which must be different from |
| 75 // AudioManager::GetTaskRunner to be meaningful. | 77 // AudioManager::GetTaskRunner to be meaningful. |
| 76 // This must be called only after an AudioManager instance is created. | 78 // This must be called only after an AudioManager instance is created. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // an empty string. Must be called on the audio worker thread (see | 243 // an empty string. Must be called on the audio worker thread (see |
| 242 // GetTaskRunner()). | 244 // GetTaskRunner()). |
| 243 virtual std::string GetAssociatedOutputDeviceID( | 245 virtual std::string GetAssociatedOutputDeviceID( |
| 244 const std::string& input_device_id) = 0; | 246 const std::string& input_device_id) = 0; |
| 245 | 247 |
| 246 // Create a new AudioLog object for tracking the behavior for one or more | 248 // Create a new AudioLog object for tracking the behavior for one or more |
| 247 // instances of the given component. See AudioLogFactory for more details. | 249 // instances of the given component. See AudioLogFactory for more details. |
| 248 virtual std::unique_ptr<AudioLog> CreateAudioLog( | 250 virtual std::unique_ptr<AudioLog> CreateAudioLog( |
| 249 AudioLogFactory::AudioComponent component) = 0; | 251 AudioLogFactory::AudioComponent component) = 0; |
| 250 | 252 |
| 253 // Create a new AudioFileWriter object for recording audio. |
| 254 virtual std::unique_ptr<AudioFileWriter> CreateAudioFileWriter( |
| 255 const AudioParameters& params) = 0; |
| 256 |
| 257 // Enable output debug recording. |
| 258 // TODO(grunell): Control input debug recording via these functions too. |
| 259 virtual void EnableOutputDebugRecording( |
| 260 const base::FilePath& base_file_name) = 0; |
| 261 |
| 262 // Disable output debug recording. |
| 263 virtual void DisableOutputDebugRecording() = 0; |
| 264 |
| 251 // Gets the name of the audio manager (e.g., Windows, Mac, PulseAudio). | 265 // Gets the name of the audio manager (e.g., Windows, Mac, PulseAudio). |
| 252 virtual const char* GetName() = 0; | 266 virtual const char* GetName() = 0; |
| 253 | 267 |
| 254 // Limits the number of streams that can be created for testing purposes. | 268 // Limits the number of streams that can be created for testing purposes. |
| 255 virtual void SetMaxStreamCountForTesting(int max_input, int max_output); | 269 virtual void SetMaxStreamCountForTesting(int max_input, int max_output); |
| 256 | 270 |
| 257 protected: | 271 protected: |
| 258 AudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 272 AudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 259 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner); | 273 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner); |
| 260 virtual ~AudioManager(); | 274 virtual ~AudioManager(); |
| 261 | 275 |
| 262 private: | 276 private: |
| 263 friend class base::DeleteHelper<AudioManager>; | 277 friend class base::DeleteHelper<AudioManager>; |
| 264 | 278 |
| 265 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 279 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 266 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; | 280 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; |
| 267 DISALLOW_COPY_AND_ASSIGN(AudioManager); | 281 DISALLOW_COPY_AND_ASSIGN(AudioManager); |
| 268 }; | 282 }; |
| 269 | 283 |
| 270 } // namespace media | 284 } // namespace media |
| 271 | 285 |
| 272 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 286 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ |
| OLD | NEW |