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 <CoreAudio/AudioHardware.h> | 5 #include <CoreAudio/AudioHardware.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | |
9 #include "base/mac/mac_logging.h" | 10 #include "base/mac/mac_logging.h" |
10 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
11 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
12 #include "media/audio/mac/audio_input_mac.h" | 13 #include "media/audio/mac/audio_input_mac.h" |
13 #include "media/audio/mac/audio_low_latency_input_mac.h" | 14 #include "media/audio/mac/audio_low_latency_input_mac.h" |
14 #include "media/audio/mac/audio_low_latency_output_mac.h" | 15 #include "media/audio/mac/audio_low_latency_output_mac.h" |
15 #include "media/audio/mac/audio_manager_mac.h" | 16 #include "media/audio/mac/audio_manager_mac.h" |
16 #include "media/audio/mac/audio_output_mac.h" | 17 #include "media/audio/mac/audio_output_mac.h" |
18 #include "media/audio/mac/audio_synchronized_mac.h" | |
17 #include "media/base/limits.h" | 19 #include "media/base/limits.h" |
20 #include "media/base/media_switches.h" | |
18 | 21 |
19 namespace media { | 22 namespace media { |
20 | 23 |
21 // Maximum number of output streams that can be open simultaneously. | 24 // Maximum number of output streams that can be open simultaneously. |
22 static const int kMaxOutputStreams = 50; | 25 static const int kMaxOutputStreams = 50; |
23 | 26 |
24 static bool HasAudioHardware(AudioObjectPropertySelector selector) { | 27 static bool HasAudioHardware(AudioObjectPropertySelector selector) { |
25 AudioDeviceID output_device_id = kAudioObjectUnknown; | 28 AudioDeviceID output_device_id = kAudioObjectUnknown; |
26 const AudioObjectPropertyAddress property_address = { | 29 const AudioObjectPropertyAddress property_address = { |
27 selector, | 30 selector, |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 | 246 |
244 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( | 247 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( |
245 const AudioParameters& params) { | 248 const AudioParameters& params) { |
246 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 249 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
247 return new PCMQueueOutAudioOutputStream(this, params); | 250 return new PCMQueueOutAudioOutputStream(this, params); |
248 } | 251 } |
249 | 252 |
250 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( | 253 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( |
251 const AudioParameters& params) { | 254 const AudioParameters& params) { |
252 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 255 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
253 return new AUAudioOutputStream(this, params); | 256 |
257 // TODO(crogers): remove once we properly handle input device selection. | |
258 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
259 switches::kEnableWebAudioInput)) { | |
260 // kAudioDeviceUnknown translates to "use default" here. | |
261 return new AudioSynchronizedStream(this, | |
262 params, | |
263 kAudioDeviceUnknown, | |
264 kAudioDeviceUnknown); | |
265 } else { | |
scherkus (not reviewing)
2012/09/17 14:51:17
nit: else not needed
Chris Rogers
2012/09/17 20:44:23
Fixed: Also, please note new logic with HasUnified
| |
266 return new AUAudioOutputStream(this, params); | |
267 } | |
254 } | 268 } |
255 | 269 |
256 AudioInputStream* AudioManagerMac::MakeLinearInputStream( | 270 AudioInputStream* AudioManagerMac::MakeLinearInputStream( |
257 const AudioParameters& params, const std::string& device_id) { | 271 const AudioParameters& params, const std::string& device_id) { |
258 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 272 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
259 return new PCMQueueInAudioInputStream(this, params); | 273 return new PCMQueueInAudioInputStream(this, params); |
260 } | 274 } |
261 | 275 |
262 AudioInputStream* AudioManagerMac::MakeLowLatencyInputStream( | 276 AudioInputStream* AudioManagerMac::MakeLowLatencyInputStream( |
263 const AudioParameters& params, const std::string& device_id) { | 277 const AudioParameters& params, const std::string& device_id) { |
264 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 278 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
265 // Gets the AudioDeviceID that refers to the AudioOutputDevice with the device | 279 // Gets the AudioDeviceID that refers to the AudioOutputDevice with the device |
266 // unique id. This AudioDeviceID is used to set the device for Audio Unit. | 280 // unique id. This AudioDeviceID is used to set the device for Audio Unit. |
267 AudioDeviceID audio_device_id = GetAudioDeviceIdByUId(true, device_id); | 281 AudioDeviceID audio_device_id = GetAudioDeviceIdByUId(true, device_id); |
268 AudioInputStream* stream = NULL; | 282 AudioInputStream* stream = NULL; |
269 if (audio_device_id != kAudioObjectUnknown) | 283 if (audio_device_id != kAudioObjectUnknown) |
270 stream = new AUAudioInputStream(this, params, audio_device_id); | 284 stream = new AUAudioInputStream(this, params, audio_device_id); |
271 | 285 |
272 return stream; | 286 return stream; |
273 } | 287 } |
274 | 288 |
275 AudioManager* CreateAudioManager() { | 289 AudioManager* CreateAudioManager() { |
276 return new AudioManagerMac(); | 290 return new AudioManagerMac(); |
277 } | 291 } |
278 | 292 |
279 } // namespace media | 293 } // namespace media |
OLD | NEW |