Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: media/audio/audio_manager.h

Issue 1864483002: Forward output glitch information from stream WebRTC log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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
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 LogCallback = base::Callback<void(const std::string&)>;
139
135 // Factory for all the supported stream formats. |params| defines parameters 140 // Factory for all the supported stream formats. |params| defines parameters
136 // of the audio stream to be created. 141 // of the audio stream to be created.
137 // 142 //
138 // |params.sample_per_packet| is the requested buffer allocation which the 143 // |params.sample_per_packet| is the requested buffer allocation which the
139 // audio source thinks it can usually fill without blocking. Internally two 144 // 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 145 // 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(). 146 // be ready to be filled in the call to AudioSourceCallback::OnMoreData().
142 // 147 //
143 // To create a stream for the default output device, pass an empty string 148 // 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. 149 // for |device_id|, otherwise the specified audio device will be opened.
145 // 150 //
146 // Returns NULL if the combination of the parameters is not supported, or if 151 // Returns NULL if the combination of the parameters is not supported, or if
147 // we have reached some other platform specific limit. 152 // we have reached some other platform specific limit.
148 // 153 //
149 // |params.format| can be set to AUDIO_PCM_LOW_LATENCY and that has two 154 // |params.format| can be set to AUDIO_PCM_LOW_LATENCY and that has two
150 // effects: 155 // effects:
151 // 1- Instead of triple buffered the audio will be double buffered. 156 // 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 157 // 2- A low latency driver or alternative audio subsystem will be used when
153 // available. 158 // available.
154 // 159 //
155 // Do not free the returned AudioOutputStream. It is owned by AudioManager. 160 // Do not free the returned AudioOutputStream. It is owned by AudioManager.
156 virtual AudioOutputStream* MakeAudioOutputStream( 161 virtual AudioOutputStream* MakeAudioOutputStream(
157 const AudioParameters& params, 162 const AudioParameters& params,
158 const std::string& device_id) = 0; 163 const std::string& device_id,
164 const LogCallback& log_callback) = 0;
159 165
160 // Creates new audio output proxy. A proxy implements 166 // Creates new audio output proxy. A proxy implements
161 // AudioOutputStream interface, but unlike regular output stream 167 // AudioOutputStream interface, but unlike regular output stream
162 // created with MakeAudioOutputStream() it opens device only when a 168 // created with MakeAudioOutputStream() it opens device only when a
163 // sound is actually playing. 169 // sound is actually playing.
164 virtual AudioOutputStream* MakeAudioOutputStreamProxy( 170 virtual AudioOutputStream* MakeAudioOutputStreamProxy(
165 const AudioParameters& params, 171 const AudioParameters& params,
166 const std::string& device_id) = 0; 172 const std::string& device_id) = 0;
167 173
168 // Factory to create audio recording streams. 174 // Factory to create audio recording streams.
169 // |channels| can be 1 or 2. 175 // |channels| can be 1 or 2.
170 // |sample_rate| is in hertz and can be any value supported by the platform. 176 // |sample_rate| is in hertz and can be any value supported by the platform.
171 // |bits_per_sample| can be any value supported by the platform. 177 // |bits_per_sample| can be any value supported by the platform.
172 // |samples_per_packet| is in hertz as well and can be 0 to |sample_rate|, 178 // |samples_per_packet| is in hertz as well and can be 0 to |sample_rate|,
173 // with 0 suggesting that the implementation use a default value for that 179 // with 0 suggesting that the implementation use a default value for that
174 // platform. 180 // platform.
175 // Returns NULL if the combination of the parameters is not supported, or if 181 // Returns NULL if the combination of the parameters is not supported, or if
176 // we have reached some other platform specific limit. 182 // we have reached some other platform specific limit.
177 // 183 //
178 // Do not free the returned AudioInputStream. It is owned by AudioManager. 184 // Do not free the returned AudioInputStream. It is owned by AudioManager.
179 // When you are done with it, call |Stop()| and |Close()| to release it. 185 // When you are done with it, call |Stop()| and |Close()| to release it.
180 virtual AudioInputStream* MakeAudioInputStream( 186 virtual AudioInputStream* MakeAudioInputStream(
181 const AudioParameters& params, 187 const AudioParameters& params,
182 const std::string& device_id) = 0; 188 const std::string& device_id,
189 const LogCallback& log_callback) = 0;
183 190
184 // Returns the task runner used for audio IO. 191 // Returns the task runner used for audio IO.
185 // TODO(alokp): Rename to task_runner(). 192 // TODO(alokp): Rename to task_runner().
186 base::SingleThreadTaskRunner* GetTaskRunner() const { 193 base::SingleThreadTaskRunner* GetTaskRunner() const {
187 return task_runner_.get(); 194 return task_runner_.get();
188 } 195 }
189 196
190 // Heavyweight tasks should use GetWorkerTaskRunner() instead of 197 // Heavyweight tasks should use GetWorkerTaskRunner() instead of
191 // GetTaskRunner(). On most platforms they are the same, but some share the 198 // GetTaskRunner(). On most platforms they are the same, but some share the
192 // UI loop with the audio IO loop. 199 // UI loop with the audio IO loop.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
OLDNEW
« no previous file with comments | « media/audio/audio_low_latency_input_output_unittest.cc ('k') | media/audio/audio_manager_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698