From 627e7bc136622483f09138505a2c695194ffea0a Mon Sep 17 00:00:00 2001 From: "henrika@chromium.org" Date: Tue, 6 Mar 2012 21:07:52 +0000 Subject: Adds input volume control support for Windows platforms. This CL also adds a device_id input parameter to media::GetAudioInputHardwareSampleRate() and media::GetAudioInputHardwareChannelCount(). We need this new flexibility to be able to perform unit tests where the volume is modified for all supported devices. Without it, we will not be able to open the audio-input stream using the correct sample rate and channels count for all devices since all we can get information about is the default device. BUG=115013 TEST=media_unittests Review URL: http://codereview.chromium.org/9585010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125222 0039d316-1c4b-4281-b951-d872f2087c98 --- media/audio/audio_util.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'media/audio/audio_util.cc') diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc index 0ce05fa..b387ce7 100644 --- a/media/audio/audio_util.cc +++ b/media/audio/audio_util.cc @@ -17,6 +17,7 @@ #include "base/time.h" #if defined(OS_WIN) #include "base/win/windows_version.h" +#include "media/audio/audio_manager_base.h" #endif #include "media/audio/audio_parameters.h" #include "media/audio/audio_util.h" @@ -262,24 +263,17 @@ double GetAudioHardwareSampleRate() { #endif } -double GetAudioInputHardwareSampleRate() { +double GetAudioInputHardwareSampleRate(const std::string& device_id) { + // TODO(henrika): add support for device selection on all platforms. + // Only exists on Windows today. #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 (!IsWASAPISupported()) { - // Fall back to Windows Wave implementation on Windows XP or lower - // and use 48kHz as default input sample rate. return 48000.0; } - - // 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); + return WASAPIAudioInputStream::HardwareSampleRate(device_id); #else - // Hardware for Linux is nearly always 48KHz. - // TODO(henrika): return correct value in rare non-48KHz cases. return 48000.0; #endif } @@ -315,7 +309,9 @@ size_t GetAudioHardwareBufferSize() { #endif } -uint32 GetAudioInputHardwareChannelCount() { +uint32 GetAudioInputHardwareChannelCount(const std::string& device_id) { + // TODO(henrika): add support for device selection on all platforms. + // Only exists on Windows today. enum channel_layout { MONO = 1, STEREO = 2 }; #if defined(OS_MACOSX) return MONO; @@ -325,7 +321,7 @@ uint32 GetAudioInputHardwareChannelCount() { // use stereo by default. return STEREO; } - return WASAPIAudioInputStream::HardwareChannelCount(eConsole); + return WASAPIAudioInputStream::HardwareChannelCount(device_id); #else return STEREO; #endif -- cgit v1.1