Chromium Code Reviews| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 AudioDeviceID audio_device_id = GetAudioDeviceIdByUId(true, device_id); | 329 AudioDeviceID audio_device_id = GetAudioDeviceIdByUId(true, device_id); |
| 330 AudioInputStream* stream = NULL; | 330 AudioInputStream* stream = NULL; |
| 331 if (audio_device_id != kAudioObjectUnknown) | 331 if (audio_device_id != kAudioObjectUnknown) |
| 332 stream = new AUAudioInputStream(this, params, audio_device_id); | 332 stream = new AUAudioInputStream(this, params, audio_device_id); |
| 333 | 333 |
| 334 return stream; | 334 return stream; |
| 335 } | 335 } |
| 336 | 336 |
| 337 AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters( | 337 AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters( |
| 338 const AudioParameters& input_params) { | 338 const AudioParameters& input_params) { |
| 339 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 339 ChannelLayout channel_layout = CHANNEL_LAYOUT_UNSUPPORTED; |
| 340 | |
| 340 int input_channels = 0; | 341 int input_channels = 0; |
| 341 if (input_params.IsValid()) { | 342 if (input_params.IsValid()) { |
| 342 channel_layout = input_params.channel_layout(); | 343 channel_layout = input_params.channel_layout(); |
|
DaleCurtis
2013/03/06 19:19:30
Instead of doing this I think you should use FFmpe
Chris Rogers
2013/03/07 00:34:17
I think I've changed it to be more in line with yo
| |
| 343 input_channels = input_params.input_channels(); | 344 input_channels = input_params.input_channels(); |
| 344 | 345 |
| 345 if (CommandLine::ForCurrentProcess()->HasSwitch( | 346 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 346 switches::kEnableWebAudioInput)) { | 347 switches::kEnableWebAudioInput)) { |
| 347 // TODO(crogers): given the limitations of the AudioOutputStream | 348 // TODO(crogers): given the limitations of the AudioOutputStream |
| 348 // back-ends used with kEnableWebAudioInput, we hard-code to stereo. | 349 // back-ends used with kEnableWebAudioInput, we hard-code to stereo. |
| 349 // Specifically, this is a limitation of AudioSynchronizedStream which | 350 // Specifically, this is a limitation of AudioSynchronizedStream which |
| 350 // can be removed as part of the work to consolidate these back-ends. | 351 // can be removed as part of the work to consolidate these back-ends. |
| 351 channel_layout = CHANNEL_LAYOUT_STEREO; | 352 channel_layout = CHANNEL_LAYOUT_STEREO; |
| 352 } | 353 } |
| 353 } | 354 } |
| 354 | 355 |
| 355 return AudioParameters( | 356 AudioParameters params( |
| 356 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, | 357 AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 357 AUAudioOutputStream::HardwareSampleRate(), 16, | 358 channel_layout, |
| 359 input_channels, | |
| 360 AUAudioOutputStream::HardwareSampleRate(), | |
| 361 16, | |
| 358 kDefaultLowLatencyBufferSize); | 362 kDefaultLowLatencyBufferSize); |
| 363 | |
| 364 if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) { | |
| 365 int channels = 2; | |
| 366 int channels_per_frame; | |
| 367 AudioHardwareUnifiedStream::GetDefaultOutputChannels( | |
| 368 &channels, &channels_per_frame); | |
|
DaleCurtis
2013/03/06 19:19:30
4 space indent.
Chris Rogers
2013/03/07 00:34:17
Done.
| |
| 369 | |
| 370 params.SetDiscreteChannels(channels); | |
| 371 } | |
| 372 | |
| 373 return params; | |
| 359 } | 374 } |
| 360 | 375 |
| 361 void AudioManagerMac::CreateDeviceListener() { | 376 void AudioManagerMac::CreateDeviceListener() { |
| 362 DCHECK(GetMessageLoop()->BelongsToCurrentThread()); | 377 DCHECK(GetMessageLoop()->BelongsToCurrentThread()); |
| 363 output_device_listener_.reset(new AudioDeviceListenerMac(base::Bind( | 378 output_device_listener_.reset(new AudioDeviceListenerMac(base::Bind( |
| 364 &AudioManagerMac::DelayedDeviceChange, base::Unretained(this)))); | 379 &AudioManagerMac::DelayedDeviceChange, base::Unretained(this)))); |
| 365 } | 380 } |
| 366 | 381 |
| 367 void AudioManagerMac::DestroyDeviceListener() { | 382 void AudioManagerMac::DestroyDeviceListener() { |
| 368 DCHECK(GetMessageLoop()->BelongsToCurrentThread()); | 383 DCHECK(GetMessageLoop()->BelongsToCurrentThread()); |
| 369 output_device_listener_.reset(); | 384 output_device_listener_.reset(); |
| 370 } | 385 } |
| 371 | 386 |
| 372 void AudioManagerMac::DelayedDeviceChange() { | 387 void AudioManagerMac::DelayedDeviceChange() { |
| 373 // TODO(dalecurtis): This is ridiculous, but we need to delay device changes | 388 // TODO(dalecurtis): This is ridiculous, but we need to delay device changes |
| 374 // to workaround threading issues with OSX property listener callbacks. See | 389 // to workaround threading issues with OSX property listener callbacks. See |
| 375 // http://crbug.com/158170 | 390 // http://crbug.com/158170 |
| 376 GetMessageLoop()->PostDelayedTask(FROM_HERE, base::Bind( | 391 GetMessageLoop()->PostDelayedTask(FROM_HERE, base::Bind( |
| 377 &AudioManagerMac::NotifyAllOutputDeviceChangeListeners, | 392 &AudioManagerMac::NotifyAllOutputDeviceChangeListeners, |
| 378 base::Unretained(this)), base::TimeDelta::FromSeconds(2)); | 393 base::Unretained(this)), base::TimeDelta::FromSeconds(2)); |
| 379 } | 394 } |
| 380 | 395 |
| 381 AudioManager* CreateAudioManager() { | 396 AudioManager* CreateAudioManager() { |
| 382 return new AudioManagerMac(); | 397 return new AudioManagerMac(); |
| 383 } | 398 } |
| 384 | 399 |
| 385 } // namespace media | 400 } // namespace media |
| OLD | NEW |