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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 9 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
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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return 480; 302 return 480;
303 else if (mixing_sample_rate == 44100) 303 else if (mixing_sample_rate == 44100)
304 return 448; 304 return 448;
305 else 305 else
306 return 960; 306 return 960;
307 #else 307 #else
308 return 2048; 308 return 2048;
309 #endif 309 #endif
310 } 310 }
311 311
312 uint32 GetAudioInputHardwareChannelCount(const std::string& device_id) { 312 ChannelLayout GetAudioInputHardwareChannelLayout(const std::string& device_id) {
313 // TODO(henrika): add support for device selection on all platforms. 313 // TODO(henrika): add support for device selection on all platforms.
314 // Only exists on Windows today. 314 // Only exists on Windows today.
315 enum channel_layout { MONO = 1, STEREO = 2 };
316 #if defined(OS_MACOSX) 315 #if defined(OS_MACOSX)
317 return MONO; 316 return CHANNEL_LAYOUT_MONO;
318 #elif defined(OS_WIN) 317 #elif defined(OS_WIN)
319 if (!IsWASAPISupported()) { 318 if (!IsWASAPISupported()) {
320 // Fall back to Windows Wave implementation on Windows XP or lower and 319 // Fall back to Windows Wave implementation on Windows XP or lower and
321 // use stereo by default. 320 // use stereo by default.
322 return STEREO; 321 return CHANNEL_LAYOUT_STEREO;
323 } 322 }
324 return WASAPIAudioInputStream::HardwareChannelCount(device_id); 323 return WASAPIAudioInputStream::HardwareChannelCount(device_id) == 1 ?
324 CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO;
325 #else 325 #else
326 return STEREO; 326 return CHANNEL_LAYOUT_STEREO;
327 #endif 327 #endif
328 } 328 }
329 329
330 // When transferring data in the shared memory, first word is size of data 330 // When transferring data in the shared memory, first word is size of data
331 // in bytes. Actual data starts immediately after it. 331 // in bytes. Actual data starts immediately after it.
332 332
333 uint32 TotalSharedMemorySizeInBytes(uint32 packet_size) { 333 uint32 TotalSharedMemorySizeInBytes(uint32 packet_size) {
334 // Need to reserve extra 4 bytes for size of data. 334 // Need to reserve extra 4 bytes for size of data.
335 return packet_size + sizeof(Atomic32); 335 return packet_size + sizeof(Atomic32);
336 } 336 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 bool IsWASAPISupported() { 382 bool IsWASAPISupported() {
383 // Note: that function correctly returns that Windows Server 2003 does not 383 // Note: that function correctly returns that Windows Server 2003 does not
384 // support WASAPI. 384 // support WASAPI.
385 return base::win::GetVersion() >= base::win::VERSION_VISTA; 385 return base::win::GetVersion() >= base::win::VERSION_VISTA;
386 } 386 }
387 387
388 #endif 388 #endif
389 389
390 } // namespace media 390 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698