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

Side by Side Diff: media/audio/audio_util.cc

Issue 10952024: Adding pulseaudio input support to chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and addressed Dale's final comments. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/linux/audio_manager_linux.h » ('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 // Software adjust volume of samples, allows each audio stream its own 5 // Software adjust volume of samples, allows each audio stream its own
6 // volume without impacting master volume for chrome and other applications. 6 // volume without impacting master volume for chrome and other applications.
7 7
8 // Implemented as templates to allow 8, 16 and 32 bit implementations. 8 // Implemented as templates to allow 8, 16 and 32 bit implementations.
9 // 8 bit is unsigned and biased by 128. 9 // 8 bit is unsigned and biased by 128.
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 132
133 // Hardware sample-rate on Windows can be configured, so we must query. 133 // Hardware sample-rate on Windows can be configured, so we must query.
134 // TODO(henrika): improve possibility to specify an audio endpoint. 134 // TODO(henrika): improve possibility to specify an audio endpoint.
135 // Use the default device (same as for Wave) for now to be compatible. 135 // Use the default device (same as for Wave) for now to be compatible.
136 return WASAPIAudioOutputStream::HardwareSampleRate(); 136 return WASAPIAudioOutputStream::HardwareSampleRate();
137 #elif defined(OS_ANDROID) 137 #elif defined(OS_ANDROID)
138 // TODO(leozwang): return native sampling rate on Android. 138 // TODO(leozwang): return native sampling rate on Android.
139 return 16000; 139 return 16000;
140 #else 140 #else
141 // Hardware for Linux is nearly always 48KHz.
142 // TODO(crogers) : return correct value in rare non-48KHz cases.
143 return 48000; 141 return 48000;
144 #endif 142 #endif
145 } 143 }
146 144
147 int GetAudioInputHardwareSampleRate(const std::string& device_id) { 145 int GetAudioInputHardwareSampleRate(const std::string& device_id) {
148 // TODO(henrika): add support for device selection on all platforms. 146 // TODO(henrika): add support for device selection on all platforms.
149 // Only exists on Windows today. 147 // Only exists on Windows today.
150 #if defined(OS_MACOSX) 148 #if defined(OS_MACOSX)
151 return AUAudioInputStream::HardwareSampleRate(); 149 return AUAudioInputStream::HardwareSampleRate();
152 #elif defined(OS_WIN) 150 #elif defined(OS_WIN)
153 if (!CoreAudioUtil::IsSupported()) { 151 if (!CoreAudioUtil::IsSupported()) {
154 return 48000; 152 return 48000;
155 } 153 }
156 return WASAPIAudioInputStream::HardwareSampleRate(device_id); 154 return WASAPIAudioInputStream::HardwareSampleRate(device_id);
157 #elif defined(OS_ANDROID) 155 #elif defined(OS_ANDROID)
158 return 16000; 156 return 16000;
159 #else 157 #else
158 // Hardware for Linux is nearly always 48KHz.
159 // TODO(crogers) : return correct value in rare non-48KHz cases.
160 return 48000; 160 return 48000;
161 #endif 161 #endif
162 } 162 }
163 163
164 size_t GetAudioHardwareBufferSize() { 164 size_t GetAudioHardwareBufferSize() {
165 int user_buffer_size = GetUserBufferSize(); 165 int user_buffer_size = GetUserBufferSize();
166 if (user_buffer_size) 166 if (user_buffer_size)
167 return user_buffer_size; 167 return user_buffer_size;
168 168
169 // The sizes here were determined by experimentation and are roughly 169 // The sizes here were determined by experimentation and are roughly
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // out performance was degraded compared to XP. 278 // out performance was degraded compared to XP.
279 // - The regression was fixed in Windows 7 and most configurations will work 279 // - The regression was fixed in Windows 7 and most configurations will work
280 // with 2, but some (e.g., some Sound Blasters) still need 3. 280 // with 2, but some (e.g., some Sound Blasters) still need 3.
281 // - Some XP configurations (even multi-processor ones) also need 3. 281 // - Some XP configurations (even multi-processor ones) also need 3.
282 return (base::win::GetVersion() == base::win::VERSION_VISTA) ? 4 : 3; 282 return (base::win::GetVersion() == base::win::VERSION_VISTA) ? 4 : 3;
283 } 283 }
284 284
285 #endif 285 #endif
286 286
287 } // namespace media 287 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/linux/audio_manager_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698