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

Unified Diff: media/audio/audio_util.cc

Issue 8283032: Low-latency AudioInputStream implementation based on WASAPI for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Now uses ScopedCoMem in base/win Created 9 years, 2 months 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 106687)
+++ media/audio/audio_util.cc (working copy)
@@ -14,10 +14,17 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/shared_memory.h"
+#if defined(OS_WIN)
+#include "base/win/windows_version.h"
+#endif
#include "media/audio/audio_util.h"
#if defined(OS_MACOSX)
+#include "media/audio/mac/audio_low_latency_input_mac.h"
#include "media/audio/mac/audio_low_latency_output_mac.h"
#endif
+#if defined(OS_WIN)
+#include "media/audio/win/audio_low_latency_input_win.h"
+#endif
using base::subtle::Atomic32;
@@ -230,8 +237,7 @@
}
}
-double GetAudioHardwareSampleRate()
-{
+double GetAudioHardwareSampleRate() {
#if defined(OS_MACOSX)
// Hardware sample-rate on the Mac can be configured, so we must query.
return AUAudioOutputStream::HardwareSampleRate();
@@ -242,6 +248,28 @@
#endif
}
+double GetAudioInputHardwareSampleRate() {
+#if defined(OS_MACOSX)
+ // Hardware sample-rate on the Mac can be configured, so we must query.
+ return AUAudioInputStream::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 WASAPIAudioInputStream::HardwareSampleRate(eConsole);
+ }
+#else
+ // Hardware for Linux is nearly always 48KHz.
+ // TODO(henrika): return correct value in rare non-48KHz cases.
+ return 48000.0;
+#endif
+}
+
size_t GetAudioHardwareBufferSize() {
// The sizes here were determined by experimentation and are roughly
// the lowest value (for low latency) that still allowed glitch-free

Powered by Google App Engine
This is Rietveld 408576698