| 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 <AudioUnit/AudioUnit.h> | 8 #include <AudioUnit/AudioUnit.h> |
| 9 #include <CoreAudio/AudioHardware.h> | 9 #include <CoreAudio/AudioHardware.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <list> | 11 #include <list> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "media/audio/audio_manager_base.h" | 16 #include "media/audio/audio_manager_base.h" |
| 17 #include "media/audio/mac/audio_device_listener_mac.h" | 17 #include "media/audio/mac/audio_device_listener_mac.h" |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 | 20 |
| 21 class AUAudioInputStream; | 21 class AUAudioInputStream; |
| 22 class AUHALStream; | 22 class AUHALStream; |
| 23 | 23 |
| 24 // Mac OS X implementation of the AudioManager singleton. This class is internal | 24 // Mac OS X implementation of the AudioManager singleton. This class is internal |
| 25 // to the audio output and only internal users can call methods not exposed by | 25 // to the audio output and only internal users can call methods not exposed by |
| 26 // the AudioManager class. | 26 // the AudioManager class. |
| 27 class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase { | 27 class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase { |
| 28 public: | 28 public: |
| 29 AudioManagerMac(AudioLogFactory* audio_log_factory); | 29 AudioManagerMac( |
| 30 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 31 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
| 32 AudioLogFactory* audio_log_factory); |
| 30 | 33 |
| 31 // Implementation of AudioManager. | 34 // Implementation of AudioManager. |
| 32 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override; | |
| 33 scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() override; | |
| 34 bool HasAudioOutputDevices() override; | 35 bool HasAudioOutputDevices() override; |
| 35 bool HasAudioInputDevices() override; | 36 bool HasAudioInputDevices() override; |
| 36 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; | 37 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; |
| 37 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; | 38 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; |
| 38 AudioParameters GetInputStreamParameters( | 39 AudioParameters GetInputStreamParameters( |
| 39 const std::string& device_id) override; | 40 const std::string& device_id) override; |
| 40 std::string GetAssociatedOutputDeviceID( | 41 std::string GetAssociatedOutputDeviceID( |
| 41 const std::string& input_device_id) override; | 42 const std::string& input_device_id) override; |
| 42 | 43 |
| 43 // Implementation of AudioManagerBase. | 44 // Implementation of AudioManagerBase. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 108 |
| 108 protected: | 109 protected: |
| 109 ~AudioManagerMac() override; | 110 ~AudioManagerMac() override; |
| 110 | 111 |
| 111 AudioParameters GetPreferredOutputStreamParameters( | 112 AudioParameters GetPreferredOutputStreamParameters( |
| 112 const std::string& output_device_id, | 113 const std::string& output_device_id, |
| 113 const AudioParameters& input_params) override; | 114 const AudioParameters& input_params) override; |
| 114 | 115 |
| 115 private: | 116 private: |
| 116 void InitializeOnAudioThread(); | 117 void InitializeOnAudioThread(); |
| 117 void ShutdownOnAudioThread(); | |
| 118 | 118 |
| 119 int ChooseBufferSize(bool is_input, int sample_rate); | 119 int ChooseBufferSize(bool is_input, int sample_rate); |
| 120 | 120 |
| 121 // Notify streams of a device change if the default output device or its | 121 // Notify streams of a device change if the default output device or its |
| 122 // sample rate has changed, otherwise does nothing. | 122 // sample rate has changed, otherwise does nothing. |
| 123 void HandleDeviceChanges(); | 123 void HandleDeviceChanges(); |
| 124 | 124 |
| 125 scoped_ptr<AudioDeviceListenerMac> output_device_listener_; | 125 scoped_ptr<AudioDeviceListenerMac> output_device_listener_; |
| 126 | 126 |
| 127 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 128 scoped_ptr<base::Thread> worker_thread_; | |
| 129 | |
| 130 // Track the output sample-rate and the default output device | 127 // Track the output sample-rate and the default output device |
| 131 // so we can intelligently handle device notifications only when necessary. | 128 // so we can intelligently handle device notifications only when necessary. |
| 132 int current_sample_rate_; | 129 int current_sample_rate_; |
| 133 AudioDeviceID current_output_device_; | 130 AudioDeviceID current_output_device_; |
| 134 | 131 |
| 135 // Helper class which monitors power events to determine if output streams | 132 // Helper class which monitors power events to determine if output streams |
| 136 // should defer Start() calls. Required to workaround an OSX bug. See | 133 // should defer Start() calls. Required to workaround an OSX bug. See |
| 137 // http://crbug.com/160920 for more details. | 134 // http://crbug.com/160920 for more details. |
| 138 class AudioPowerObserver; | 135 class AudioPowerObserver; |
| 139 scoped_ptr<AudioPowerObserver> power_observer_; | 136 scoped_ptr<AudioPowerObserver> power_observer_; |
| 140 | 137 |
| 141 // Tracks all constructed input and output streams so they can be stopped at | 138 // Tracks all constructed input and output streams so they can be stopped at |
| 142 // shutdown. See ShutdownOnAudioThread() for more details. | 139 // shutdown. See ShutdownOnAudioThread() for more details. |
| 143 std::list<AudioInputStream*> basic_input_streams_; | 140 std::list<AudioInputStream*> basic_input_streams_; |
| 144 std::list<AUAudioInputStream*> low_latency_input_streams_; | 141 std::list<AUAudioInputStream*> low_latency_input_streams_; |
| 145 std::list<AUHALStream*> output_streams_; | 142 std::list<AUHALStream*> output_streams_; |
| 146 | 143 |
| 147 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); | 144 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); |
| 148 }; | 145 }; |
| 149 | 146 |
| 150 } // namespace media | 147 } // namespace media |
| 151 | 148 |
| 152 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ | 149 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ |
| OLD | NEW |