Index: media/audio/audio_util.cc |
=================================================================== |
--- media/audio/audio_util.cc (revision 107928) |
+++ media/audio/audio_util.cc (working copy) |
@@ -24,6 +24,7 @@ |
#endif |
#if defined(OS_WIN) |
#include "media/audio/win/audio_low_latency_input_win.h" |
+#include "media/audio/win/audio_low_latency_output_win.h" |
#endif |
using base::subtle::Atomic32; |
@@ -241,8 +242,19 @@ |
#if defined(OS_MACOSX) |
// Hardware sample-rate on the Mac can be configured, so we must query. |
return AUAudioOutputStream::HardwareSampleRate(); |
+#elif defined(OS_WIN) |
+ if (base::win::GetVersion() <= base::win::VERSION_XP) { |
+ // Fall back to Windows Wave implementation on Windows XP or lower |
+ // and use 48kHz as default input sample rate. |
+ return 48000.0; |
+ } else { |
+ // Hardware sample-rate on Windows can be configured, so we must query. |
+ // TODO(henrika): improve possibility to specify audio endpoint. |
+ // Use the default device (same as for Wave) for now to be compatible. |
+ return WASAPIAudioOutputStream::HardwareSampleRate(eConsole); |
+ } |
#else |
- // Hardware for Windows and Linux is nearly always 48KHz. |
+ // Hardware for Linux is nearly always 48KHz. |
// TODO(crogers) : return correct value in rare non-48KHz cases. |
return 48000.0; |
#endif |
@@ -275,13 +287,21 @@ |
// the lowest value (for low latency) that still allowed glitch-free |
// audio under high loads. |
// |
- // For Mac OS X the chromium audio backend uses a low-latency |
- // CoreAudio API, so a low buffer size is possible. For other OSes, |
- // further tuning may be needed. |
+ // For Mac OS X and Windows the chromium audio backend uses a low-latency |
+ // Core Audio API, so a low buffer size is possible. For Linux, further |
+ // tuning may be needed. |
+ // TODO(crogers): figure out the best possible buffer sizes for WebAudio. |
#if defined(OS_MACOSX) |
return 128; |
-#elif defined(OS_LINUX) |
- return 2048; |
+#elif defined(OS_WIN) |
+ int mixing_sample_rate = |
+ static_cast<int>(WASAPIAudioOutputStream::HardwareSampleRate(eConsole)); |
+ if (mixing_sample_rate == 48000 || mixing_sample_rate == 44100) |
+ return 1024; |
+ else if (mixing_sample_rate == 96000) |
+ return 2048; |
+ else |
+ return 2048; |
#else |
return 2048; |
#endif |