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_name.h" | 17 #include "media/audio/audio_device_description.h" |
18 #include "media/audio/audio_logging.h" | 18 #include "media/audio/audio_logging.h" |
19 #include "media/base/audio_parameters.h" | 19 #include "media/base/audio_parameters.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
23 } | 23 } |
24 | 24 |
25 namespace media { | 25 namespace media { |
26 | 26 |
27 class AudioInputStream; | 27 class AudioInputStream; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Returns a human readable string for the model/make of the active audio | 110 // Returns a human readable string for the model/make of the active audio |
111 // input device for this computer. | 111 // input device for this computer. |
112 virtual base::string16 GetAudioInputDeviceModel() = 0; | 112 virtual base::string16 GetAudioInputDeviceModel() = 0; |
113 | 113 |
114 // Opens the platform default audio input settings UI. | 114 // Opens the platform default audio input settings UI. |
115 // Note: This could invoke an external application/preferences pane, so | 115 // Note: This could invoke an external application/preferences pane, so |
116 // ideally must not be called from the UI thread or other time sensitive | 116 // ideally must not be called from the UI thread or other time sensitive |
117 // threads to avoid blocking the rest of the application. | 117 // threads to avoid blocking the rest of the application. |
118 virtual void ShowAudioInputSettings() = 0; | 118 virtual void ShowAudioInputSettings() = 0; |
119 | 119 |
120 // Appends a list of available input devices to |device_names|, | 120 // Appends a list of available input devices to |device_descriptions|, |
121 // which must initially be empty. It is not guaranteed that all the | 121 // which must initially be empty. It is not guaranteed that all the |
122 // devices in the list support all formats and sample rates for | 122 // devices in the list support all formats and sample rates for |
123 // recording. | 123 // recording. |
124 // | 124 // |
125 // Not threadsafe; in production this should only be called from the | 125 // Not threadsafe; in production this should only be called from the |
126 // Audio worker thread (see GetTaskRunner()). | 126 // Audio worker thread (see GetTaskRunner()). |
127 virtual void GetAudioInputDeviceNames(AudioDeviceNames* device_names) = 0; | 127 virtual void GetAudioInputDeviceDescriptions( |
| 128 AudioDeviceDescriptions* device_descriptions) = 0; |
128 | 129 |
129 // Appends a list of available output devices to |device_names|, | 130 // Appends a list of available output devices to |device_descriptions|, |
130 // which must initially be empty. | 131 // which must initially be empty. |
131 // | 132 // |
132 // Not threadsafe; in production this should only be called from the | 133 // Not threadsafe; in production this should only be called from the |
133 // Audio worker thread (see GetTaskRunner()). | 134 // Audio worker thread (see GetTaskRunner()). |
134 virtual void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) = 0; | 135 virtual void GetAudioOutputDeviceDescriptions( |
| 136 AudioDeviceDescriptions* device_descriptions) = 0; |
135 | 137 |
136 // Log callback used for sending log messages from a stream to the object | 138 // Log callback used for sending log messages from a stream to the object |
137 // that manages the stream. | 139 // that manages the stream. |
138 using LogCallback = base::Callback<void(const std::string&)>; | 140 using LogCallback = base::Callback<void(const std::string&)>; |
139 | 141 |
140 // Factory for all the supported stream formats. |params| defines parameters | 142 // Factory for all the supported stream formats. |params| defines parameters |
141 // of the audio stream to be created. | 143 // of the audio stream to be created. |
142 // | 144 // |
143 // |params.sample_per_packet| is the requested buffer allocation which the | 145 // |params.sample_per_packet| is the requested buffer allocation which the |
144 // audio source thinks it can usually fill without blocking. Internally two | 146 // audio source thinks it can usually fill without blocking. Internally two |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // Returns the device id of an output device that belongs to the same hardware | 236 // Returns the device id of an output device that belongs to the same hardware |
235 // as the specified input device. | 237 // as the specified input device. |
236 // If the hardware has only an input device (e.g. a webcam), the return value | 238 // If the hardware has only an input device (e.g. a webcam), the return value |
237 // will be empty (which the caller can then interpret to be the default output | 239 // will be empty (which the caller can then interpret to be the default output |
238 // device). Implementations that don't yet support this feature, must return | 240 // device). Implementations that don't yet support this feature, must return |
239 // an empty string. Must be called on the audio worker thread (see | 241 // an empty string. Must be called on the audio worker thread (see |
240 // GetTaskRunner()). | 242 // GetTaskRunner()). |
241 virtual std::string GetAssociatedOutputDeviceID( | 243 virtual std::string GetAssociatedOutputDeviceID( |
242 const std::string& input_device_id) = 0; | 244 const std::string& input_device_id) = 0; |
243 | 245 |
244 // These functions assign group ids to devices based on their device ids. | |
245 // The default implementation is an attempt to do this based on | |
246 // GetAssociatedOutputDeviceID. Must be called on the audio worker thread | |
247 // (see GetTaskRunner()). | |
248 virtual std::string GetGroupIDOutput(const std::string& output_device_id) = 0; | |
249 virtual std::string GetGroupIDInput(const std::string& input_device_id) = 0; | |
250 | |
251 // Create a new AudioLog object for tracking the behavior for one or more | 246 // Create a new AudioLog object for tracking the behavior for one or more |
252 // instances of the given component. See AudioLogFactory for more details. | 247 // instances of the given component. See AudioLogFactory for more details. |
253 virtual std::unique_ptr<AudioLog> CreateAudioLog( | 248 virtual std::unique_ptr<AudioLog> CreateAudioLog( |
254 AudioLogFactory::AudioComponent component) = 0; | 249 AudioLogFactory::AudioComponent component) = 0; |
255 | 250 |
256 // Gets the name of the audio manager (e.g., Windows, Mac, PulseAudio). | 251 // Gets the name of the audio manager (e.g., Windows, Mac, PulseAudio). |
257 virtual const char* GetName() = 0; | 252 virtual const char* GetName() = 0; |
258 | 253 |
259 protected: | 254 protected: |
260 AudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 255 AudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
261 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner); | 256 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner); |
262 virtual ~AudioManager(); | 257 virtual ~AudioManager(); |
263 | 258 |
264 private: | 259 private: |
265 friend class base::DeleteHelper<AudioManager>; | 260 friend class base::DeleteHelper<AudioManager>; |
266 | 261 |
267 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 262 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
268 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; | 263 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; |
269 DISALLOW_COPY_AND_ASSIGN(AudioManager); | 264 DISALLOW_COPY_AND_ASSIGN(AudioManager); |
270 }; | 265 }; |
271 | 266 |
272 } // namespace media | 267 } // namespace media |
273 | 268 |
274 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 269 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ |
OLD | NEW |