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 |
11 // TODO(vrk): This file has been running pretty wild and free, and it's likely | 11 // TODO(vrk): This file has been running pretty wild and free, and it's likely |
12 // that a lot of the functions can be simplified and made more elegant. Revisit | 12 // that a lot of the functions can be simplified and made more elegant. Revisit |
13 // after other audio cleanup is done. (crbug.com/120319) | 13 // after other audio cleanup is done. (crbug.com/120319) |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include <limits> | 16 #include <limits> |
17 | 17 |
18 #include "base/atomicops.h" | 18 #include "base/atomicops.h" |
19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/shared_memory.h" | 21 #include "base/shared_memory.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 24 #include "base/sys_info.h" |
24 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
25 #include "media/audio/audio_manager_base.h" | 26 #include "media/audio/audio_manager_base.h" |
26 #endif | 27 #endif |
27 #include "media/audio/audio_parameters.h" | 28 #include "media/audio/audio_parameters.h" |
28 #include "media/audio/audio_util.h" | 29 #include "media/audio/audio_util.h" |
29 #if defined(OS_MACOSX) | 30 #if defined(OS_MACOSX) |
30 #include "media/audio/mac/audio_low_latency_input_mac.h" | 31 #include "media/audio/mac/audio_low_latency_input_mac.h" |
31 #include "media/audio/mac/audio_low_latency_output_mac.h" | 32 #include "media/audio/mac/audio_low_latency_output_mac.h" |
32 #endif | 33 #endif |
33 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 513 } |
513 | 514 |
514 #if defined(OS_WIN) | 515 #if defined(OS_WIN) |
515 | 516 |
516 bool IsWASAPISupported() { | 517 bool IsWASAPISupported() { |
517 // Note: that function correctly returns that Windows Server 2003 does not | 518 // Note: that function correctly returns that Windows Server 2003 does not |
518 // support WASAPI. | 519 // support WASAPI. |
519 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 520 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
520 } | 521 } |
521 | 522 |
| 523 int NumberOfWaveOutBuffers() { |
| 524 // Simple heuristic: use 3 buffers on single-core system or on Vista, |
| 525 // 2 otherwise. |
| 526 // Entire Windows audio stack was rewritten for Windows Vista, and wave out |
| 527 // API is simulated on top of new API, so there is noticeable performance |
| 528 // degradation compared to Windows XP. Part of regression was fixed in |
| 529 // Windows 7. Maybe it is fixed in Vista Serice Pack, but let's be cautious. |
| 530 if ((base::SysInfo::NumberOfProcessors() < 2) || |
| 531 (base::win::GetVersion() == base::win::VERSION_VISTA)) { |
| 532 return 3; |
| 533 } |
| 534 return 2; |
| 535 } |
| 536 |
522 #endif | 537 #endif |
523 | 538 |
524 } // namespace media | 539 } // namespace media |
OLD | NEW |