| 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 #ifndef MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ | 5 #ifndef MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ |
| 6 #define MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ | 6 #define MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ |
| 7 | 7 |
| 8 #include <CoreAudio/AudioHardware.h> | 8 #include <CoreAudio/AudioHardware.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "media/audio/audio_manager_base.h" | 13 #include "media/audio/audio_manager_base.h" |
| 14 #include "media/audio/mac/aggregate_device_manager.h" | |
| 15 #include "media/audio/mac/audio_device_listener_mac.h" | 14 #include "media/audio/mac/audio_device_listener_mac.h" |
| 16 | 15 |
| 17 namespace media { | 16 namespace media { |
| 18 | 17 |
| 19 // Mac OS X implementation of the AudioManager singleton. This class is internal | 18 // Mac OS X implementation of the AudioManager singleton. This class is internal |
| 20 // to the audio output and only internal users can call methods not exposed by | 19 // to the audio output and only internal users can call methods not exposed by |
| 21 // the AudioManager class. | 20 // the AudioManager class. |
| 22 class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase { | 21 class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase { |
| 23 public: | 22 public: |
| 24 AudioManagerMac(AudioLogFactory* audio_log_factory); | 23 AudioManagerMac(AudioLogFactory* audio_log_factory); |
| 25 | 24 |
| 26 // Implementation of AudioManager. | 25 // Implementation of AudioManager. |
| 27 virtual bool HasAudioOutputDevices() OVERRIDE; | 26 virtual bool HasAudioOutputDevices() OVERRIDE; |
| 28 virtual bool HasAudioInputDevices() OVERRIDE; | 27 virtual bool HasAudioInputDevices() OVERRIDE; |
| 29 virtual void GetAudioInputDeviceNames( | 28 virtual void GetAudioInputDeviceNames( |
| 30 AudioDeviceNames* device_names) OVERRIDE; | 29 AudioDeviceNames* device_names) OVERRIDE; |
| 31 virtual void GetAudioOutputDeviceNames( | 30 virtual void GetAudioOutputDeviceNames( |
| 32 AudioDeviceNames* device_names) OVERRIDE; | 31 AudioDeviceNames* device_names) OVERRIDE; |
| 33 virtual AudioParameters GetInputStreamParameters( | 32 virtual AudioParameters GetInputStreamParameters( |
| 34 const std::string& device_id) OVERRIDE; | 33 const std::string& device_id) OVERRIDE; |
| 35 virtual std::string GetAssociatedOutputDeviceID( | 34 virtual std::string GetAssociatedOutputDeviceID( |
| 36 const std::string& input_device_id) OVERRIDE; | 35 const std::string& input_device_id) OVERRIDE; |
| 37 | 36 |
| 38 // Implementation of AudioManagerBase. | 37 // Implementation of AudioManagerBase. |
| 39 virtual AudioOutputStream* MakeLinearOutputStream( | 38 virtual AudioOutputStream* MakeLinearOutputStream( |
| 40 const AudioParameters& params) OVERRIDE; | 39 const AudioParameters& params) OVERRIDE; |
| 41 virtual AudioOutputStream* MakeLowLatencyOutputStream( | 40 virtual AudioOutputStream* MakeLowLatencyOutputStream( |
| 42 const AudioParameters& params, | 41 const AudioParameters& params, |
| 43 const std::string& device_id, | 42 const std::string& device_id) OVERRIDE; |
| 44 const std::string& input_device_id) OVERRIDE; | |
| 45 virtual AudioInputStream* MakeLinearInputStream( | 43 virtual AudioInputStream* MakeLinearInputStream( |
| 46 const AudioParameters& params, const std::string& device_id) OVERRIDE; | 44 const AudioParameters& params, const std::string& device_id) OVERRIDE; |
| 47 virtual AudioInputStream* MakeLowLatencyInputStream( | 45 virtual AudioInputStream* MakeLowLatencyInputStream( |
| 48 const AudioParameters& params, const std::string& device_id) OVERRIDE; | 46 const AudioParameters& params, const std::string& device_id) OVERRIDE; |
| 49 virtual std::string GetDefaultOutputDeviceID() OVERRIDE; | 47 virtual std::string GetDefaultOutputDeviceID() OVERRIDE; |
| 50 | 48 |
| 51 static bool GetDefaultInputDevice(AudioDeviceID* device); | 49 static bool GetDefaultInputDevice(AudioDeviceID* device); |
| 52 static bool GetDefaultOutputDevice(AudioDeviceID* device); | 50 static bool GetDefaultOutputDevice(AudioDeviceID* device); |
| 53 static bool GetDefaultDevice(AudioDeviceID* device, bool input); | 51 static bool GetDefaultDevice(AudioDeviceID* device, bool input); |
| 54 | 52 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 73 bool ShouldDeferOutputStreamStart(); | 71 bool ShouldDeferOutputStreamStart(); |
| 74 | 72 |
| 75 protected: | 73 protected: |
| 76 virtual ~AudioManagerMac(); | 74 virtual ~AudioManagerMac(); |
| 77 | 75 |
| 78 virtual AudioParameters GetPreferredOutputStreamParameters( | 76 virtual AudioParameters GetPreferredOutputStreamParameters( |
| 79 const std::string& output_device_id, | 77 const std::string& output_device_id, |
| 80 const AudioParameters& input_params) OVERRIDE; | 78 const AudioParameters& input_params) OVERRIDE; |
| 81 | 79 |
| 82 private: | 80 private: |
| 83 bool HasUnifiedDefaultIO(); | |
| 84 | |
| 85 // Helper methods for constructing AudioDeviceListenerMac on the audio thread. | 81 // Helper methods for constructing AudioDeviceListenerMac on the audio thread. |
| 86 void CreateDeviceListener(); | 82 void CreateDeviceListener(); |
| 87 void DestroyDeviceListener(); | 83 void DestroyDeviceListener(); |
| 88 | 84 |
| 89 int ChooseBufferSize(int output_sample_rate); | 85 int ChooseBufferSize(int output_sample_rate); |
| 90 | 86 |
| 91 // Notify streams of a device change if the default output device or its | 87 // Notify streams of a device change if the default output device or its |
| 92 // sample rate has changed, otherwise does nothing. | 88 // sample rate has changed, otherwise does nothing. |
| 93 void HandleDeviceChanges(); | 89 void HandleDeviceChanges(); |
| 94 | 90 |
| 95 scoped_ptr<AudioDeviceListenerMac> output_device_listener_; | 91 scoped_ptr<AudioDeviceListenerMac> output_device_listener_; |
| 96 | 92 |
| 97 // Track the output sample-rate and the default output device | 93 // Track the output sample-rate and the default output device |
| 98 // so we can intelligently handle device notifications only when necessary. | 94 // so we can intelligently handle device notifications only when necessary. |
| 99 int current_sample_rate_; | 95 int current_sample_rate_; |
| 100 AudioDeviceID current_output_device_; | 96 AudioDeviceID current_output_device_; |
| 101 | 97 |
| 102 AggregateDeviceManager aggregate_device_manager_; | |
| 103 | |
| 104 // Helper class which monitors power events to determine if output streams | 98 // Helper class which monitors power events to determine if output streams |
| 105 // should defer Start() calls. Required to workaround an OSX bug. See | 99 // should defer Start() calls. Required to workaround an OSX bug. See |
| 106 // http://crbug.com/160920 for more details. | 100 // http://crbug.com/160920 for more details. |
| 107 class AudioPowerObserver; | 101 class AudioPowerObserver; |
| 108 scoped_ptr<AudioPowerObserver> power_observer_; | 102 scoped_ptr<AudioPowerObserver> power_observer_; |
| 109 | 103 |
| 110 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); | 104 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); |
| 111 }; | 105 }; |
| 112 | 106 |
| 113 } // namespace media | 107 } // namespace media |
| 114 | 108 |
| 115 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ | 109 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ |
| OLD | NEW |