diff options
author | crogers@google.com <crogers@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 20:37:56 +0000 |
---|---|---|
committer | crogers@google.com <crogers@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 20:37:56 +0000 |
commit | 88d09084af8f9d81aff56f183b196337690e7aac (patch) | |
tree | 47374c57a5155f2d9f26ee27d58ac996e69f6e56 /media | |
parent | 93f59c4e342fc2dabc56e207f5e25b993daf3a82 (diff) | |
download | chromium_src-88d09084af8f9d81aff56f183b196337690e7aac.zip chromium_src-88d09084af8f9d81aff56f183b196337690e7aac.tar.gz chromium_src-88d09084af8f9d81aff56f183b196337690e7aac.tar.bz2 |
Allow kEnableWebAudioInput to play nicely with WebRTC on OSX
WebRTC is sending out a mono signal which AudioSynchronizedStream is
unable to handle since it is currently limited to stereo.
This change makes sure that we convert correctly to stereo and
don't fallback to the high-latency path.
BUG=162064
TEST=manual tests:
https://webrtc-demos.appspot.com/html/pc1.html
http://chromium.googlecode.com/svn/trunk/samples/audio/visualizer-live.html
Review URL: https://chromiumcodereview.appspot.com/11418125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/mac/audio_manager_mac.cc | 18 | ||||
-rw-r--r-- | media/audio/mac/audio_manager_mac.h | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc index 4197c8f..9258929 100644 --- a/media/audio/mac/audio_manager_mac.cc +++ b/media/audio/mac/audio_manager_mac.cc @@ -12,6 +12,7 @@ #include "base/mac/mac_logging.h" #include "base/mac/scoped_cftyperef.h" #include "base/sys_string_conversions.h" +#include "media/audio/audio_util.h" #include "media/audio/mac/audio_input_mac.h" #include "media/audio/mac/audio_low_latency_input_mac.h" #include "media/audio/mac/audio_low_latency_output_mac.h" @@ -371,6 +372,23 @@ AudioInputStream* AudioManagerMac::MakeLowLatencyInputStream( return stream; } +AudioParameters AudioManagerMac::GetPreferredLowLatencyOutputStreamParameters( + const AudioParameters& input_params) { + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableWebAudioInput)) { + // TODO(crogers): given the limitations of the AudioOutputStream + // back-ends used with kEnableWebAudioInput, we hard-code to stereo. + // Specifically, this is a limitation of AudioSynchronizedStream which + // can be removed as part of the work to consolidate these back-ends. + return AudioParameters( + AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, + GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize()); + } + + return AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters( + input_params); +} + void AudioManagerMac::OnDeviceChange() { CHECK(creating_message_loop_->BelongsToCurrentThread()); diff --git a/media/audio/mac/audio_manager_mac.h b/media/audio/mac/audio_manager_mac.h index 80db260..d8b6b2d 100644 --- a/media/audio/mac/audio_manager_mac.h +++ b/media/audio/mac/audio_manager_mac.h @@ -34,6 +34,8 @@ class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase { const AudioParameters& params, const std::string& device_id) OVERRIDE; virtual AudioInputStream* MakeLowLatencyInputStream( const AudioParameters& params, const std::string& device_id) OVERRIDE; + virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters( + const AudioParameters& input_params) OVERRIDE; // Called by an internal device change listener. Must be called on // |creating_message_loop_|. |