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

Unified Diff: media/audio/audio_util.cc

Issue 8440002: Low-latency AudioOutputStream implementation based on WASAPI for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Minor fix in unit test Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/audio_util.cc
===================================================================
--- media/audio/audio_util.cc (revision 108984)
+++ 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 {
scherkus (not reviewing) 2011/11/08 23:52:21 nit: no need for else statement if you return
henrika (OOO until Aug 14) 2011/11/09 13:59:22 Done.
+ // 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)
scherkus (not reviewing) 2011/11/08 23:52:21 ditto
henrika (OOO until Aug 14) 2011/11/09 13:59:22 Done.
+ return 2048;
+ else
+ return 2048;
#else
return 2048;
#endif

Powered by Google App Engine
This is Rietveld 408576698