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

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

Issue 285233005: add audio-buffer-size command line flag support to the input audio for all the platforms (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « media/audio/audio_input_proxy.cc ('k') | media/audio/audio_manager_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BASE_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "media/audio/audio_manager.h" 16 #include "media/audio/audio_manager.h"
17 17
18 #include "media/audio/audio_output_dispatcher.h" 18 #include "media/audio/audio_output_dispatcher.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #include "base/win/scoped_com_initializer.h" 21 #include "base/win/scoped_com_initializer.h"
22 #endif 22 #endif
23 23
24 namespace media { 24 namespace media {
25 25
26 class AudioInputProxy;
26 class AudioOutputDispatcher; 27 class AudioOutputDispatcher;
27 28
28 // AudioManagerBase provides AudioManager functions common for all platforms. 29 // AudioManagerBase provides AudioManager functions common for all platforms.
29 class MEDIA_EXPORT AudioManagerBase : public AudioManager { 30 class MEDIA_EXPORT AudioManagerBase : public AudioManager {
30 public: 31 public:
31 // TODO(sergeyu): The constants below belong to AudioManager interface, not 32 // TODO(sergeyu): The constants below belong to AudioManager interface, not
32 // to the base implementation. 33 // to the base implementation.
33 34
34 // Name of the generic "default" device. 35 // Name of the generic "default" device.
35 static const char kDefaultDeviceName[]; 36 static const char kDefaultDeviceName[];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // streams. If the users inject a valid |input_params|, each AudioManager 144 // streams. If the users inject a valid |input_params|, each AudioManager
144 // will decide if they should return the values from |input_params| or the 145 // will decide if they should return the values from |input_params| or the
145 // default hardware values. If the |input_params| is invalid, it will return 146 // default hardware values. If the |input_params| is invalid, it will return
146 // the default hardware audio parameters. 147 // the default hardware audio parameters.
147 // If |output_device_id| is empty, the implementation must treat that as 148 // If |output_device_id| is empty, the implementation must treat that as
148 // a request for the default output device. 149 // a request for the default output device.
149 virtual AudioParameters GetPreferredOutputStreamParameters( 150 virtual AudioParameters GetPreferredOutputStreamParameters(
150 const std::string& output_device_id, 151 const std::string& output_device_id,
151 const AudioParameters& input_params) = 0; 152 const AudioParameters& input_params) = 0;
152 153
154 // Returns the preferred hardware audio output parameters for opening input
155 // streams. If the users inject a valid |input_params|, each AudioManager
156 // will decide if they should return the values from |input_params| or the
157 // default hardware values. If the |input_params| is invalid, it will return
158 // the default hardware audio parameters.
159 // If |input_device_id| is empty, the implementation must treat that as
160 // a request for the default output device.
161 virtual AudioParameters GetPreferredInputStreamParameters(
162 const std::string& input_device_id,
163 const AudioParameters& input_params) = 0;
164
153 // Returns the ID of the default audio output device. 165 // Returns the ID of the default audio output device.
154 // Implementations that don't yet support this should return an empty string. 166 // Implementations that don't yet support this should return an empty string.
155 virtual std::string GetDefaultOutputDeviceID(); 167 virtual std::string GetDefaultOutputDeviceID();
156 168
157 private: 169 private:
158 struct DispatcherParams; 170 struct DispatcherParams;
159 typedef ScopedVector<DispatcherParams> AudioOutputDispatchers; 171 typedef ScopedVector<DispatcherParams> AudioOutputDispatchers;
172 typedef ScopedVector<AudioInputProxy> AudioInputProxies;
160 173
161 class CompareByParams; 174 class CompareByParams;
162 175
163 // Called by Shutdown(). 176 // Called by Shutdown().
164 void ShutdownOnAudioThread(); 177 void ShutdownOnAudioThread();
165 178
179 // Helper for MakeAudioInputStream() to get the supported hardware
180 // format for the new stream.
181 AudioParameters GetSupportedInputHardwareParameters(
182 const std::string& device_id, const AudioParameters& preferred_params);
183
166 // Max number of open output streams, modified by 184 // Max number of open output streams, modified by
167 // SetMaxOutputStreamsAllowed(). 185 // SetMaxOutputStreamsAllowed().
168 int max_num_output_streams_; 186 int max_num_output_streams_;
169 187
170 // Max number of open input streams. 188 // Max number of open input streams.
171 int max_num_input_streams_; 189 int max_num_input_streams_;
172 190
173 // Number of currently open output streams. 191 // Number of currently open output streams.
174 int num_output_streams_; 192 int num_output_streams_;
175 193
176 // Number of currently open input streams. 194 // Number of currently open input streams.
177 int num_input_streams_; 195 int num_input_streams_;
178 196
179 // Track output state change listeners. 197 // Track output state change listeners.
180 ObserverList<AudioDeviceListener> output_listeners_; 198 ObserverList<AudioDeviceListener> output_listeners_;
181 199
182 // Thread used to interact with audio streams created by this audio manager. 200 // Thread used to interact with audio streams created by this audio manager.
183 base::Thread audio_thread_; 201 base::Thread audio_thread_;
184 202
185 // The task runner of the audio thread this object runs on. Used for internal 203 // The task runner of the audio thread this object runs on. Used for internal
186 // tasks which run on the audio thread even after Shutdown() has been started 204 // tasks which run on the audio thread even after Shutdown() has been started
187 // and GetTaskRunner() starts returning NULL. 205 // and GetTaskRunner() starts returning NULL.
188 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 206 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
189 207
190 // Map of cached AudioOutputDispatcher instances. Must only be touched 208 // Vector of cached AudioOutputDispatcher instances. Must only be touched
191 // from the audio thread (no locking). 209 // on the audio thread (no locking).
192 AudioOutputDispatchers output_dispatchers_; 210 AudioOutputDispatchers output_dispatchers_;
193 211
212 // Vector of cached AudioInputProxy instances. Must only be touched on
213 // the audio thread.
214 AudioInputProxies input_proxies_;
215
194 // Proxy for creating AudioLog objects. 216 // Proxy for creating AudioLog objects.
195 AudioLogFactory* const audio_log_factory_; 217 AudioLogFactory* const audio_log_factory_;
196 218
197 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); 219 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase);
198 }; 220 };
199 221
200 } // namespace media 222 } // namespace media
201 223
202 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 224 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
OLDNEW
« no previous file with comments | « media/audio/audio_input_proxy.cc ('k') | media/audio/audio_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698