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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void ShutdownOnAudioThread(); | 118 void ShutdownOnAudioThread(); |
118 | 119 |
119 int ChooseBufferSize(bool is_input, int sample_rate); | 120 int ChooseBufferSize(bool is_input, int sample_rate); |
120 | 121 |
121 // Notify streams of a device change if the default output device or its | 122 // Notify streams of a device change if the default output device or its |
122 // sample rate has changed, otherwise does nothing. | 123 // sample rate has changed, otherwise does nothing. |
123 void HandleDeviceChanges(); | 124 void HandleDeviceChanges(); |
124 | 125 |
125 scoped_ptr<AudioDeviceListenerMac> output_device_listener_; | 126 scoped_ptr<AudioDeviceListenerMac> output_device_listener_; |
126 | 127 |
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 | 128 // Track the output sample-rate and the default output device |
131 // so we can intelligently handle device notifications only when necessary. | 129 // so we can intelligently handle device notifications only when necessary. |
132 int current_sample_rate_; | 130 int current_sample_rate_; |
133 AudioDeviceID current_output_device_; | 131 AudioDeviceID current_output_device_; |
134 | 132 |
135 // Helper class which monitors power events to determine if output streams | 133 // Helper class which monitors power events to determine if output streams |
136 // should defer Start() calls. Required to workaround an OSX bug. See | 134 // should defer Start() calls. Required to workaround an OSX bug. See |
137 // http://crbug.com/160920 for more details. | 135 // http://crbug.com/160920 for more details. |
138 class AudioPowerObserver; | 136 class AudioPowerObserver; |
139 scoped_ptr<AudioPowerObserver> power_observer_; | 137 scoped_ptr<AudioPowerObserver> power_observer_; |
140 | 138 |
141 // Tracks all constructed input and output streams so they can be stopped at | 139 // Tracks all constructed input and output streams so they can be stopped at |
142 // shutdown. See ShutdownOnAudioThread() for more details. | 140 // shutdown. See ShutdownOnAudioThread() for more details. |
143 std::list<AudioInputStream*> basic_input_streams_; | 141 std::list<AudioInputStream*> basic_input_streams_; |
144 std::list<AUAudioInputStream*> low_latency_input_streams_; | 142 std::list<AUAudioInputStream*> low_latency_input_streams_; |
145 std::list<AUHALStream*> output_streams_; | 143 std::list<AUHALStream*> output_streams_; |
146 | 144 |
147 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); | 145 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); |
148 }; | 146 }; |
149 | 147 |
150 } // namespace media | 148 } // namespace media |
151 | 149 |
152 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ | 150 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ |
OLD | NEW |