summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_util.cc
diff options
context:
space:
mode:
authorhenrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-06 21:07:52 +0000
committerhenrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-06 21:07:52 +0000
commit627e7bc136622483f09138505a2c695194ffea0a (patch)
treea25b314f6c04ce3f2bb1a694f5e74e750150fa1c /media/audio/audio_util.cc
parent16969f048808af3157a8d75bee3cd285a5527f7e (diff)
downloadchromium_src-627e7bc136622483f09138505a2c695194ffea0a.zip
chromium_src-627e7bc136622483f09138505a2c695194ffea0a.tar.gz
chromium_src-627e7bc136622483f09138505a2c695194ffea0a.tar.bz2
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
Diffstat (limited to 'media/audio/audio_util.cc')
-rw-r--r--media/audio/audio_util.cc22
1 files changed, 9 insertions, 13 deletions
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