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

Unified Diff: media/audio/mac/audio_manager_mac.cc

Issue 13403002: Add OSX aggregate audio device support for best performance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 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/mac/audio_manager_mac.cc
===================================================================
--- media/audio/mac/audio_manager_mac.cc (revision 191870)
+++ media/audio/mac/audio_manager_mac.cc (working copy)
@@ -426,24 +426,53 @@
AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream(
const AudioParameters& params) {
+ // Handle basic output with no input channels.
+ if (params.input_channels() == 0) {
+ AudioDeviceID device = kAudioObjectUnknown;
+ GetDefaultOutputDevice(&device);
+ return new AUHALStream(this, params, device);
+ }
+
// TODO(crogers): support more than stereo input.
- if (params.input_channels() == 2) {
- if (HasUnifiedDefaultIO())
- return new AudioHardwareUnifiedStream(this, params);
+ if (params.input_channels() != 2) {
+ // WebAudio is currently hard-coded to 2 channels so we should not
+ // see this case.
+ NOTREACHED() << "Only stereo input is currently supported!";
+ return NULL;
+ }
- // TODO(crogers): use aggregate devices along with AUHALStream
- // to get better performance for built-in hardware.
-
- // kAudioDeviceUnknown translates to "use default" here.
- return new AudioSynchronizedStream(this,
- params,
- kAudioDeviceUnknown,
- kAudioDeviceUnknown);
+ AudioDeviceID device = kAudioObjectUnknown;
+ if (HasUnifiedDefaultIO()) {
+ // For I/O, the simplest case is when the default input and output
+ // devices are the same.
+ GetDefaultOutputDevice(&device);
+ LOG(INFO) << "UNIFIED: default input and output devices are identical";
no longer working on chromium 2013/04/17 09:16:22 just a thought, do you want to use uma to record t
Chris Rogers 2013/04/17 20:42:31 Not a bad idea - for now added TODO
+ } else {
+ // Some audio hardware is presented as separate input and output devices
+ // even though they are really the same physical hardware and
+ // share the same "clock domain" at the lowest levels of the driver.
+ // A common of example of this is the "built-in" audio hardware:
+ // "Built-in Line Input"
+ // "Built-in Output"
+ // We would like to use an "aggregate" device for these situations, since
+ // CoreAudio will make the most efficient use of the shared "clock domain"
+ // so we get the lowest latency and use fewer threads.
+ device = aggregate_device_manager_.GetDefaultAggregateDevice();
+ if (device != kAudioObjectUnknown)
+ LOG(INFO) << "Using AGGREGATE audio device";
}
- AudioDeviceID device = kAudioObjectUnknown;
- GetDefaultOutputDevice(&device);
- return new AUHALStream(this, params, device);
+ if (device != kAudioObjectUnknown)
+ return new AUHALStream(this, params, device);
+
+ // Fallback to AudioSynchronizedStream which will handle completely
+ // different and arbitrary combinations of input and output devices
+ // even running at different sample-rates.
+ // kAudioDeviceUnknown translates to "use default" here.
+ return new AudioSynchronizedStream(this,
+ params,
+ kAudioDeviceUnknown,
+ kAudioDeviceUnknown);
}
AudioInputStream* AudioManagerMac::MakeLinearInputStream(

Powered by Google App Engine
This is Rietveld 408576698