OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/audio/mac/audio_manager_mac.h" | 5 #include "media/audio/mac/audio_manager_mac.h" |
6 | 6 |
7 #include <CoreAudio/AudioHardware.h> | 7 #include <CoreAudio/AudioHardware.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 buffer_size); | 420 buffer_size); |
421 } | 421 } |
422 | 422 |
423 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( | 423 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( |
424 const AudioParameters& params) { | 424 const AudioParameters& params) { |
425 return MakeLowLatencyOutputStream(params); | 425 return MakeLowLatencyOutputStream(params); |
426 } | 426 } |
427 | 427 |
428 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( | 428 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( |
429 const AudioParameters& params) { | 429 const AudioParameters& params) { |
430 // Handle basic output with no input channels. | |
431 if (params.input_channels() == 0) { | |
432 AudioDeviceID device = kAudioObjectUnknown; | |
433 GetDefaultOutputDevice(&device); | |
434 return new AUHALStream(this, params, device); | |
435 } | |
436 | |
430 // TODO(crogers): support more than stereo input. | 437 // TODO(crogers): support more than stereo input. |
431 if (params.input_channels() == 2) { | 438 if (params.input_channels() != 2) { |
432 if (HasUnifiedDefaultIO()) | 439 // WebAudio is currently hard-coded to 2 channels so we should not |
433 return new AudioHardwareUnifiedStream(this, params); | 440 // see this case. |
441 NOTREACHED() << "Only stereo input is currently supported!"; | |
442 return NULL; | |
443 } | |
434 | 444 |
435 // TODO(crogers): use aggregate devices along with AUHALStream | 445 AudioDeviceID device = kAudioObjectUnknown; |
436 // to get better performance for built-in hardware. | 446 if (HasUnifiedDefaultIO()) { |
447 // For I/O, the simplest case is when the default input and output | |
448 // devices are the same. | |
449 GetDefaultOutputDevice(&device); | |
450 LOG(INFO) << "UNIFIED: default input and output devices are identical"; | |
451 } else if (aggregate_device_manager_.UseDefaultAggregateDevice()) { | |
452 // Some audio hardware is presented as separate input and output devices | |
453 // even though they are really the same physical hardware and | |
454 // share the same "clock domain" at the lowest levels of the driver. | |
455 // A common of example of this is the "built-in" audio hardware: | |
456 // "Built-in Line Input" | |
457 // "Built-in Output" | |
458 // We would like to use an "aggregate" device for these situations, since | |
459 // CoreAudio will make the most efficient use of the shared "clock domain" | |
460 // so we get the lowest latency and use fewer threads. | |
461 device = aggregate_device_manager_.GetDefaultAggregateDevice(); | |
462 if (device != kAudioObjectUnknown) | |
463 LOG(INFO) << "Using AGGREGATE audio device"; | |
464 } | |
437 | 465 |
466 if (device != kAudioObjectUnknown) { | |
467 return new AUHALStream(this, params, device); | |
468 } 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.
| |
469 // Fallback to AudioSynchronizedStream which will handle completely | |
470 // different and arbitrary combinations of input and output devices | |
471 // even running at different sample-rates. | |
438 // kAudioDeviceUnknown translates to "use default" here. | 472 // kAudioDeviceUnknown translates to "use default" here. |
439 return new AudioSynchronizedStream(this, | 473 return new AudioSynchronizedStream(this, |
440 params, | 474 params, |
441 kAudioDeviceUnknown, | 475 kAudioDeviceUnknown, |
442 kAudioDeviceUnknown); | 476 kAudioDeviceUnknown); |
443 } | 477 } |
444 | |
445 AudioDeviceID device = kAudioObjectUnknown; | |
446 GetDefaultOutputDevice(&device); | |
447 return new AUHALStream(this, params, device); | |
448 } | 478 } |
449 | 479 |
450 AudioInputStream* AudioManagerMac::MakeLinearInputStream( | 480 AudioInputStream* AudioManagerMac::MakeLinearInputStream( |
451 const AudioParameters& params, const std::string& device_id) { | 481 const AudioParameters& params, const std::string& device_id) { |
452 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 482 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
453 return new PCMQueueInAudioInputStream(this, params); | 483 return new PCMQueueInAudioInputStream(this, params); |
454 } | 484 } |
455 | 485 |
456 AudioInputStream* AudioManagerMac::MakeLowLatencyInputStream( | 486 AudioInputStream* AudioManagerMac::MakeLowLatencyInputStream( |
457 const AudioParameters& params, const std::string& device_id) { | 487 const AudioParameters& params, const std::string& device_id) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 current_sample_rate_ = new_sample_rate; | 561 current_sample_rate_ = new_sample_rate; |
532 current_output_device_ = new_output_device; | 562 current_output_device_ = new_output_device; |
533 NotifyAllOutputDeviceChangeListeners(); | 563 NotifyAllOutputDeviceChangeListeners(); |
534 } | 564 } |
535 | 565 |
536 AudioManager* CreateAudioManager() { | 566 AudioManager* CreateAudioManager() { |
537 return new AudioManagerMac(); | 567 return new AudioManagerMac(); |
538 } | 568 } |
539 | 569 |
540 } // namespace media | 570 } // namespace media |
OLD | NEW |