| 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" | 
|  | 11 #include "base/bind_to_current_loop.h" | 
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" | 
| 12 #include "base/mac/mac_logging.h" | 13 #include "base/mac/mac_logging.h" | 
| 13 #include "base/mac/scoped_cftyperef.h" | 14 #include "base/mac/scoped_cftyperef.h" | 
| 14 #include "base/power_monitor/power_monitor.h" | 15 #include "base/power_monitor/power_monitor.h" | 
| 15 #include "base/power_monitor/power_observer.h" | 16 #include "base/power_monitor/power_observer.h" | 
| 16 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" | 
| 17 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" | 
| 18 #include "media/audio/audio_parameters.h" | 19 #include "media/audio/audio_parameters.h" | 
| 19 #include "media/audio/mac/audio_auhal_mac.h" | 20 #include "media/audio/mac/audio_auhal_mac.h" | 
| 20 #include "media/audio/mac/audio_input_mac.h" | 21 #include "media/audio/mac/audio_input_mac.h" | 
| 21 #include "media/audio/mac/audio_low_latency_input_mac.h" | 22 #include "media/audio/mac/audio_low_latency_input_mac.h" | 
| 22 #include "media/base/bind_to_current_loop.h" |  | 
| 23 #include "media/base/channel_layout.h" | 23 #include "media/base/channel_layout.h" | 
| 24 #include "media/base/limits.h" | 24 #include "media/base/limits.h" | 
| 25 #include "media/base/media_switches.h" | 25 #include "media/base/media_switches.h" | 
| 26 | 26 | 
| 27 namespace media { | 27 namespace media { | 
| 28 | 28 | 
| 29 // Maximum number of output streams that can be open simultaneously. | 29 // Maximum number of output streams that can be open simultaneously. | 
| 30 static const int kMaxOutputStreams = 50; | 30 static const int kMaxOutputStreams = 50; | 
| 31 | 31 | 
| 32 // Define bounds for for low-latency input and output streams. | 32 // Define bounds for for low-latency input and output streams. | 
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 560     return NULL; | 560     return NULL; | 
| 561   } | 561   } | 
| 562 | 562 | 
| 563   // Lazily create the audio device listener on the first stream creation. | 563   // Lazily create the audio device listener on the first stream creation. | 
| 564   if (!output_device_listener_) { | 564   if (!output_device_listener_) { | 
| 565     // NOTE: Use BindToCurrentLoop() to ensure the callback is always PostTask'd | 565     // NOTE: Use BindToCurrentLoop() to ensure the callback is always PostTask'd | 
| 566     // even if OSX calls us on the right thread.  Some CoreAudio drivers will | 566     // even if OSX calls us on the right thread.  Some CoreAudio drivers will | 
| 567     // fire the callbacks during stream creation, leading to re-entrancy issues | 567     // fire the callbacks during stream creation, leading to re-entrancy issues | 
| 568     // otherwise.  See http://crbug.com/349604 | 568     // otherwise.  See http://crbug.com/349604 | 
| 569     output_device_listener_.reset( | 569     output_device_listener_.reset( | 
| 570         new AudioDeviceListenerMac(BindToCurrentLoop(base::Bind( | 570         new AudioDeviceListenerMac(base::BindToCurrentLoop(base::Bind( | 
| 571             &AudioManagerMac::HandleDeviceChanges, base::Unretained(this))))); | 571             &AudioManagerMac::HandleDeviceChanges, base::Unretained(this))))); | 
| 572     // Only set the current output device for the default device. | 572     // Only set the current output device for the default device. | 
| 573     if (device_id == AudioManagerBase::kDefaultDeviceId || device_id.empty()) | 573     if (device_id == AudioManagerBase::kDefaultDeviceId || device_id.empty()) | 
| 574       current_output_device_ = device; | 574       current_output_device_ = device; | 
| 575     // Just use the current sample rate since we don't allow non-native sample | 575     // Just use the current sample rate since we don't allow non-native sample | 
| 576     // rates on OSX. | 576     // rates on OSX. | 
| 577     current_sample_rate_ = params.sample_rate(); | 577     current_sample_rate_ = params.sample_rate(); | 
| 578   } | 578   } | 
| 579 | 579 | 
| 580   AUHALStream* stream = new AUHALStream(this, params, device); | 580   AUHALStream* stream = new AUHALStream(this, params, device); | 
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 827     basic_input_streams_.erase(stream_it); | 827     basic_input_streams_.erase(stream_it); | 
| 828 | 828 | 
| 829   AudioManagerBase::ReleaseInputStream(stream); | 829   AudioManagerBase::ReleaseInputStream(stream); | 
| 830 } | 830 } | 
| 831 | 831 | 
| 832 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 832 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 
| 833   return new AudioManagerMac(audio_log_factory); | 833   return new AudioManagerMac(audio_log_factory); | 
| 834 } | 834 } | 
| 835 | 835 | 
| 836 }  // namespace media | 836 }  // namespace media | 
| OLD | NEW | 
|---|