| 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" | |
| 25 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
| 26 #include "media/audio/audio_manager_base.h" | 25 #include "media/audio/audio_manager_base.h" |
| 27 #endif | 26 #endif |
| 28 #include "media/audio/audio_parameters.h" | 27 #include "media/audio/audio_parameters.h" |
| 29 #include "media/audio/audio_util.h" | 28 #include "media/audio/audio_util.h" |
| 30 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
| 31 #include "media/audio/mac/audio_low_latency_input_mac.h" | 30 #include "media/audio/mac/audio_low_latency_input_mac.h" |
| 32 #include "media/audio/mac/audio_low_latency_output_mac.h" | 31 #include "media/audio/mac/audio_low_latency_output_mac.h" |
| 33 #endif | 32 #endif |
| 34 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 513 |
| 515 #if defined(OS_WIN) | 514 #if defined(OS_WIN) |
| 516 | 515 |
| 517 bool IsWASAPISupported() { | 516 bool IsWASAPISupported() { |
| 518 // Note: that function correctly returns that Windows Server 2003 does not | 517 // Note: that function correctly returns that Windows Server 2003 does not |
| 519 // support WASAPI. | 518 // support WASAPI. |
| 520 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 519 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
| 521 } | 520 } |
| 522 | 521 |
| 523 int NumberOfWaveOutBuffers() { | 522 int NumberOfWaveOutBuffers() { |
| 524 // The entire Windows audio stack was rewritten for Windows Vista, and the | 523 // Use 4 buffers for Vista, 3 for everyone else: |
| 525 // wave out API is simulated on top of new API, so there is noticeable | 524 // - The entire Windows audio stack was rewritten for Windows Vista and wave |
| 526 // performance degradation compared to Windows XP. So use 4 buffers for Vista. | 525 // out performance was degraded compared to XP. |
| 527 if (base::win::GetVersion() == base::win::VERSION_VISTA) | 526 // - The regression was fixed in Windows 7 and most configurations will work |
| 528 return 4; | 527 // with 2, but some (e.g., some Sound Blasters) still need 3. |
| 529 | 528 // - Some XP configurations (even multi-processor ones) also need 3. |
| 530 // Part of regression was apparently fixed in Windows 7, but problems remain | 529 return (base::win::GetVersion() == base::win::VERSION_VISTA) ? 4 : 3; |
| 531 // at least with some configurations (compared to XP). So use 3 buffers for | |
| 532 // Windows 7 and higher. | |
| 533 if (base::win::GetVersion() >= base::win::VERSION_WIN7) | |
| 534 return 3; | |
| 535 | |
| 536 // Otherwise (for XP), use 3 buffers on single-core systems and 2 otherwise. | |
| 537 return (base::SysInfo::NumberOfProcessors() < 2) ? 3 : 2; | |
| 538 } | 530 } |
| 539 | 531 |
| 540 #endif | 532 #endif |
| 541 | 533 |
| 542 } // namespace media | 534 } // namespace media |
| OLD | NEW |