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

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, 9 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 191629)
+++ media/audio/mac/audio_manager_mac.cc (working copy)
@@ -427,24 +427,54 @@
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.
+ 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";
+ } else if (aggregate_device_manager_.UseDefaultAggregateDevice()) {
+ // 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";
+ }
+ if (device != kAudioObjectUnknown) {
+ return new AUHALStream(this, params, device);
+ } else {
no longer working on chromium 2013/04/03 21:11:57 nit, you don't need the else
Chris Rogers 2013/04/05 20:01:38 Done.
+ // 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);
}
-
- AudioDeviceID device = kAudioObjectUnknown;
- GetDefaultOutputDevice(&device);
- return new AUHALStream(this, params, device);
}
AudioInputStream* AudioManagerMac::MakeLinearInputStream(

Powered by Google App Engine
This is Rietveld 408576698