summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhenrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 13:33:56 +0000
committerhenrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 13:33:56 +0000
commit2aab2c9b4ce3c30afac8d01b6c19a7b5b7d2ad2f (patch)
tree6bd35611a9f15031e7a0c68121b150fe2910ac8b
parent32d1eb4bfec492ba59e10a733b9afae33f4602c4 (diff)
downloadchromium_src-2aab2c9b4ce3c30afac8d01b6c19a7b5b7d2ad2f.zip
chromium_src-2aab2c9b4ce3c30afac8d01b6c19a7b5b7d2ad2f.tar.gz
chromium_src-2aab2c9b4ce3c30afac8d01b6c19a7b5b7d2ad2f.tar.bz2
Ensure that full-duplex audio test uses preferred buffer size.
The existing version does not work on Mac since it uses a hard coded buffer size and that is not allowed by the lower layers. The solution is to use the preferred buffer size instead. BUG=none TEST=media_unittests.exe --gtest_filter=AudioLow* --gtest_also_run_disabled_tests Review URL: https://codereview.chromium.org/11360168 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166906 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/audio/audio_low_latency_input_output_unittest.cc42
1 files changed, 14 insertions, 28 deletions
diff --git a/media/audio/audio_low_latency_input_output_unittest.cc b/media/audio/audio_low_latency_input_output_unittest.cc
index 7ca7f03..9376db8 100644
--- a/media/audio/audio_low_latency_input_output_unittest.cc
+++ b/media/audio/audio_low_latency_input_output_unittest.cc
@@ -291,6 +291,11 @@ class AudioInputStreamTraits {
AudioManagerBase::kDefaultDeviceId));
}
+ // TODO(henrika): add support for GetAudioInputHardwareBufferSize in media.
+ static int HardwareBufferSize() {
+ return static_cast<int>(media::GetAudioHardwareBufferSize());
+ }
+
static StreamType* CreateStream(AudioManager* audio_manager,
const AudioParameters& params) {
return audio_manager->MakeAudioInputStream(params,
@@ -306,6 +311,10 @@ class AudioOutputStreamTraits {
return static_cast<int>(media::GetAudioHardwareSampleRate());
}
+ static int HardwareBufferSize() {
+ return static_cast<int>(media::GetAudioHardwareBufferSize());
+ }
+
static StreamType* CreateStream(AudioManager* audio_manager,
const AudioParameters& params) {
return audio_manager->MakeAudioOutputStream(params);
@@ -332,35 +341,12 @@ class StreamWrapper {
channel_layout_(CHANNEL_LAYOUT_STEREO),
#endif
bits_per_sample_(16) {
- // Use native/mixing sample rate and N*10ms frame size as default,
- // where N is platform dependent.
+ // Use the preferred sample rate.
sample_rate_ = StreamTraits::HardwareSampleRate();
-#if defined(OS_MACOSX)
- // 10ms buffer size works well for 44.1, 48, 96 and 192kHz.
- samples_per_packet_ = (sample_rate_ / 100);
-#elif defined(OS_LINUX) || defined(OS_OPENBSD)
- // 10ms buffer size works well for 44.1, 48, 96 and 192kHz.
- samples_per_packet_ = (sample_rate_ / 100);
-#elif defined(OS_WIN)
- if (media::IsWASAPISupported()) {
- // WASAPI is supported for Windows Vista and higher.
- if (sample_rate_ == 44100) {
- // Tests have shown that the shared mode WASAPI implementation
- // works bests for a period size of ~10.15873 ms when the sample
- // rate is 44.1kHz.
- samples_per_packet_ = 448;
- } else {
- // 10ms buffer size works well for 48, 96 and 192kHz.
- samples_per_packet_ = (sample_rate_ / 100);
- }
- } else {
- // Low-latency Wave implementation needs 30ms buffer size to
- // ensure glitch-free output audio.
- samples_per_packet_ = 3 * (sample_rate_ / 100);
- }
-#elif defined(OS_ANDROID)
- samples_per_packet_ = (sample_rate_ / 100);
-#endif
+
+ // Use the preferred buffer size. Note that the input side uses the same
+ // size as the output side in this implementation.
+ samples_per_packet_ = StreamTraits::HardwareBufferSize();
}
virtual ~StreamWrapper() {}