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 // 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 return 480; | 330 return 480; |
331 else if (mixing_sample_rate == 44100) | 331 else if (mixing_sample_rate == 44100) |
332 return 448; | 332 return 448; |
333 else | 333 else |
334 return 960; | 334 return 960; |
335 #else | 335 #else |
336 return 2048; | 336 return 2048; |
337 #endif | 337 #endif |
338 } | 338 } |
339 | 339 |
| 340 uint32 GetAudioInputHardwareChannelCount() { |
| 341 enum channel_layout { MONO = 1, STEREO = 2 }; |
| 342 #if defined(OS_MACOSX) |
| 343 return MONO; |
| 344 #elif defined(OS_WIN) |
| 345 if (!IsWASAPISupported()) { |
| 346 // Fall back to Windows Wave implementation on Windows XP or lower and |
| 347 // use stereo by default. |
| 348 return STEREO; |
| 349 } |
| 350 return WASAPIAudioInputStream::HardwareChannelCount(eConsole); |
| 351 #else |
| 352 return STEREO; |
| 353 #endif |
| 354 } |
| 355 |
340 // When transferring data in the shared memory, first word is size of data | 356 // When transferring data in the shared memory, first word is size of data |
341 // in bytes. Actual data starts immediately after it. | 357 // in bytes. Actual data starts immediately after it. |
342 | 358 |
343 uint32 TotalSharedMemorySizeInBytes(uint32 packet_size) { | 359 uint32 TotalSharedMemorySizeInBytes(uint32 packet_size) { |
344 // Need to reserve extra 4 bytes for size of data. | 360 // Need to reserve extra 4 bytes for size of data. |
345 return packet_size + sizeof(Atomic32); | 361 return packet_size + sizeof(Atomic32); |
346 } | 362 } |
347 | 363 |
348 uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size) { | 364 uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size) { |
349 return shared_memory_created_size - sizeof(Atomic32); | 365 return shared_memory_created_size - sizeof(Atomic32); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 case 1: | 430 case 1: |
415 DoCrossfade(bytes_to_crossfade, number_of_channels, bytes_per_channel, | 431 DoCrossfade(bytes_to_crossfade, number_of_channels, bytes_per_channel, |
416 src, dest); | 432 src, dest); |
417 break; | 433 break; |
418 default: | 434 default: |
419 NOTREACHED() << "Unsupported audio bit depth in crossfade."; | 435 NOTREACHED() << "Unsupported audio bit depth in crossfade."; |
420 } | 436 } |
421 } | 437 } |
422 | 438 |
423 } // namespace media | 439 } // namespace media |
OLD | NEW |