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.h" | |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "media/audio/audio_device_name.h" | 17 #include "media/audio/audio_device_name.h" |
17 #include "media/audio/audio_logging.h" | 18 #include "media/audio/audio_logging.h" |
18 #include "media/base/audio_parameters.h" | 19 #include "media/base/audio_parameters.h" |
19 | 20 |
20 namespace base { | 21 namespace base { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 // Audio worker thread (see GetWorkerTaskRunner()). | 126 // Audio worker thread (see GetWorkerTaskRunner()). |
126 virtual void GetAudioInputDeviceNames(AudioDeviceNames* device_names) = 0; | 127 virtual void GetAudioInputDeviceNames(AudioDeviceNames* device_names) = 0; |
127 | 128 |
128 // Appends a list of available output devices to |device_names|, | 129 // Appends a list of available output devices to |device_names|, |
129 // which must initially be empty. | 130 // which must initially be empty. |
130 // | 131 // |
131 // Not threadsafe; in production this should only be called from the | 132 // Not threadsafe; in production this should only be called from the |
132 // Audio worker thread (see GetWorkerTaskRunner()). | 133 // Audio worker thread (see GetWorkerTaskRunner()). |
133 virtual void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) = 0; | 134 virtual void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) = 0; |
134 | 135 |
136 // Log callback used for sending log messages from a stream to the object | |
137 // that manages the stream. | |
138 using StatisticsCallback = | |
DaleCurtis
2016/05/19 20:34:37
Again, this should just be a base::Callback(string
Henrik Grunell
2016/05/23 17:13:54
Done.
| |
139 base::Callback<void(AudioOutputStream*, const std::string&, int)>; | |
140 | |
135 // Factory for all the supported stream formats. |params| defines parameters | 141 // Factory for all the supported stream formats. |params| defines parameters |
136 // of the audio stream to be created. | 142 // of the audio stream to be created. |
137 // | 143 // |
138 // |params.sample_per_packet| is the requested buffer allocation which the | 144 // |params.sample_per_packet| is the requested buffer allocation which the |
139 // audio source thinks it can usually fill without blocking. Internally two | 145 // audio source thinks it can usually fill without blocking. Internally two |
140 // or three buffers are created, one will be locked for playback and one will | 146 // or three buffers are created, one will be locked for playback and one will |
141 // be ready to be filled in the call to AudioSourceCallback::OnMoreData(). | 147 // be ready to be filled in the call to AudioSourceCallback::OnMoreData(). |
142 // | 148 // |
143 // To create a stream for the default output device, pass an empty string | 149 // To create a stream for the default output device, pass an empty string |
144 // for |device_id|, otherwise the specified audio device will be opened. | 150 // for |device_id|, otherwise the specified audio device will be opened. |
145 // | 151 // |
146 // Returns NULL if the combination of the parameters is not supported, or if | 152 // Returns NULL if the combination of the parameters is not supported, or if |
147 // we have reached some other platform specific limit. | 153 // we have reached some other platform specific limit. |
148 // | 154 // |
149 // |params.format| can be set to AUDIO_PCM_LOW_LATENCY and that has two | 155 // |params.format| can be set to AUDIO_PCM_LOW_LATENCY and that has two |
150 // effects: | 156 // effects: |
151 // 1- Instead of triple buffered the audio will be double buffered. | 157 // 1- Instead of triple buffered the audio will be double buffered. |
152 // 2- A low latency driver or alternative audio subsystem will be used when | 158 // 2- A low latency driver or alternative audio subsystem will be used when |
153 // available. | 159 // available. |
154 // | 160 // |
155 // Do not free the returned AudioOutputStream. It is owned by AudioManager. | 161 // Do not free the returned AudioOutputStream. It is owned by AudioManager. |
156 virtual AudioOutputStream* MakeAudioOutputStream( | 162 virtual AudioOutputStream* MakeAudioOutputStream( |
157 const AudioParameters& params, | 163 const AudioParameters& params, |
158 const std::string& device_id) = 0; | 164 const std::string& device_id, |
165 const StatisticsCallback& statistics_callback) = 0; | |
159 | 166 |
160 // Creates new audio output proxy. A proxy implements | 167 // Creates new audio output proxy. A proxy implements |
161 // AudioOutputStream interface, but unlike regular output stream | 168 // AudioOutputStream interface, but unlike regular output stream |
162 // created with MakeAudioOutputStream() it opens device only when a | 169 // created with MakeAudioOutputStream() it opens device only when a |
163 // sound is actually playing. | 170 // sound is actually playing. |
164 virtual AudioOutputStream* MakeAudioOutputStreamProxy( | 171 virtual AudioOutputStream* MakeAudioOutputStreamProxy( |
165 const AudioParameters& params, | 172 const AudioParameters& params, |
166 const std::string& device_id) = 0; | 173 const std::string& device_id) = 0; |
167 | 174 |
168 // Factory to create audio recording streams. | 175 // Factory to create audio recording streams. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 friend class base::DeleteHelper<AudioManager>; | 255 friend class base::DeleteHelper<AudioManager>; |
249 | 256 |
250 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 257 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
251 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; | 258 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; |
252 DISALLOW_COPY_AND_ASSIGN(AudioManager); | 259 DISALLOW_COPY_AND_ASSIGN(AudioManager); |
253 }; | 260 }; |
254 | 261 |
255 } // namespace media | 262 } // namespace media |
256 | 263 |
257 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 264 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ |
OLD | NEW |