Chromium Code Reviews| Index: media/audio/mac/audio_manager_mac.cc |
| =================================================================== |
| --- media/audio/mac/audio_manager_mac.cc (revision 157152) |
| +++ media/audio/mac/audio_manager_mac.cc (working copy) |
| @@ -6,6 +6,7 @@ |
| #include <string> |
| +#include "base/command_line.h" |
| #include "base/mac/mac_logging.h" |
| #include "base/mac/scoped_cftyperef.h" |
| #include "base/sys_string_conversions.h" |
| @@ -14,7 +15,10 @@ |
| #include "media/audio/mac/audio_low_latency_output_mac.h" |
| #include "media/audio/mac/audio_manager_mac.h" |
| #include "media/audio/mac/audio_output_mac.h" |
| +#include "media/audio/mac/audio_synchronized_mac.h" |
| +#include "media/audio/mac/audio_unified_mac.h" |
| #include "media/base/limits.h" |
| +#include "media/base/media_switches.h" |
| namespace media { |
| @@ -39,6 +43,44 @@ |
| output_device_id != kAudioObjectUnknown; |
| } |
| +// Returns if the default input device is the same as the default output. |
|
scherkus (not reviewing)
2012/09/17 23:07:17
Returns... true? :)
Chris Rogers
2012/09/18 00:22:36
Done.
|
| +static bool HasUnifiedDefaultIO() { |
| + AudioDeviceID input_id, output_id; |
| + |
| + AudioObjectPropertyAddress pa; |
| + pa.mSelector = kAudioHardwarePropertyDefaultInputDevice; |
| + pa.mScope = kAudioObjectPropertyScopeGlobal; |
| + pa.mElement = kAudioObjectPropertyElementMaster; |
| + UInt32 size = sizeof(input_id); |
| + |
| + // Get the default input. |
| + OSStatus result = AudioObjectGetPropertyData( |
| + kAudioObjectSystemObject, |
| + &pa, |
| + 0, |
| + 0, |
| + &size, |
| + &input_id); |
| + |
| + if (result != noErr) |
| + return false; |
| + |
| + // Get the default output. |
| + pa.mSelector = kAudioHardwarePropertyDefaultOutputDevice; |
| + result = AudioObjectGetPropertyData( |
| + kAudioObjectSystemObject, |
| + &pa, |
| + 0, |
| + 0, |
| + &size, |
| + &output_id); |
| + |
| + if (result != noErr) |
| + return false; |
| + |
| + return input_id == output_id; |
| +} |
| + |
| static void GetAudioDeviceInfo(bool is_input, |
| media::AudioDeviceNames* device_names) { |
| DCHECK(device_names); |
| @@ -250,6 +292,21 @@ |
| AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( |
| const AudioParameters& params) { |
| DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
| + |
| + // TODO(crogers): remove once we properly handle input device selection. |
| + if (CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableWebAudioInput)) { |
| + if (HasUnifiedDefaultIO()) { |
| + return new AudioHardwareUnifiedStream(this, params); |
| + } else { |
|
scherkus (not reviewing)
2012/09/17 23:07:17
nit: no need for else due to early return
Chris Rogers
2012/09/18 00:22:36
Done.
|
| + // kAudioDeviceUnknown translates to "use default" here. |
| + return new AudioSynchronizedStream(this, |
| + params, |
| + kAudioDeviceUnknown, |
| + kAudioDeviceUnknown); |
| + } |
| + } |
| + |
| return new AUAudioOutputStream(this, params); |
| } |