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_AUDIO_MANAGER_BASE_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. | 95 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. |
96 virtual AudioInputStream* MakeLowLatencyInputStream( | 96 virtual AudioInputStream* MakeLowLatencyInputStream( |
97 const AudioParameters& params, const std::string& device_id) = 0; | 97 const AudioParameters& params, const std::string& device_id) = 0; |
98 | 98 |
99 // Listeners will be notified on the GetTaskRunner() task runner. | 99 // Listeners will be notified on the GetTaskRunner() task runner. |
100 virtual void AddOutputDeviceChangeListener( | 100 virtual void AddOutputDeviceChangeListener( |
101 AudioDeviceListener* listener) OVERRIDE; | 101 AudioDeviceListener* listener) OVERRIDE; |
102 virtual void RemoveOutputDeviceChangeListener( | 102 virtual void RemoveOutputDeviceChangeListener( |
103 AudioDeviceListener* listener) OVERRIDE; | 103 AudioDeviceListener* listener) OVERRIDE; |
104 | 104 |
| 105 virtual void AddStateChangeListener(StateChangeListener* listener) OVERRIDE; |
| 106 virtual void RemoveStateChangeListener( |
| 107 StateChangeListener* listener) OVERRIDE; |
| 108 |
105 virtual AudioParameters GetDefaultOutputStreamParameters() OVERRIDE; | 109 virtual AudioParameters GetDefaultOutputStreamParameters() OVERRIDE; |
106 virtual AudioParameters GetOutputStreamParameters( | 110 virtual AudioParameters GetOutputStreamParameters( |
107 const std::string& device_id) OVERRIDE; | 111 const std::string& device_id) OVERRIDE; |
108 | 112 |
109 virtual AudioParameters GetInputStreamParameters( | 113 virtual AudioParameters GetInputStreamParameters( |
110 const std::string& device_id) OVERRIDE; | 114 const std::string& device_id) OVERRIDE; |
111 | 115 |
112 virtual std::string GetAssociatedOutputDeviceID( | 116 virtual std::string GetAssociatedOutputDeviceID( |
113 const std::string& input_device_id) OVERRIDE; | 117 const std::string& input_device_id) OVERRIDE; |
114 | 118 |
(...skipping 13 matching lines...) Expand all Loading... |
128 // implementation. | 132 // implementation. |
129 void Shutdown(); | 133 void Shutdown(); |
130 | 134 |
131 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } | 135 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } |
132 | 136 |
133 // Called by each platform specific AudioManager to notify output state change | 137 // Called by each platform specific AudioManager to notify output state change |
134 // listeners that a state change has occurred. Must be called from the audio | 138 // listeners that a state change has occurred. Must be called from the audio |
135 // thread. | 139 // thread. |
136 void NotifyAllOutputDeviceChangeListeners(); | 140 void NotifyAllOutputDeviceChangeListeners(); |
137 | 141 |
| 142 void NotifyAllStateChangeListeners(const std::string& msg); |
| 143 |
138 // Returns user buffer size as specified on the command line or 0 if no buffer | 144 // Returns user buffer size as specified on the command line or 0 if no buffer |
139 // size has been specified. | 145 // size has been specified. |
140 int GetUserBufferSize(); | 146 int GetUserBufferSize(); |
141 | 147 |
142 // Returns the preferred hardware audio output parameters for opening output | 148 // Returns the preferred hardware audio output parameters for opening output |
143 // streams. If the users inject a valid |input_params|, each AudioManager | 149 // streams. If the users inject a valid |input_params|, each AudioManager |
144 // will decide if they should return the values from |input_params| or the | 150 // will decide if they should return the values from |input_params| or the |
145 // default hardware values. If the |input_params| is invalid, it will return | 151 // default hardware values. If the |input_params| is invalid, it will return |
146 // the default hardware audio parameters. | 152 // the default hardware audio parameters. |
147 // If |output_device_id| is empty, the implementation must treat that as | 153 // If |output_device_id| is empty, the implementation must treat that as |
(...skipping 24 matching lines...) Expand all Loading... |
172 | 178 |
173 // Number of currently open output streams. | 179 // Number of currently open output streams. |
174 int num_output_streams_; | 180 int num_output_streams_; |
175 | 181 |
176 // Number of currently open input streams. | 182 // Number of currently open input streams. |
177 int num_input_streams_; | 183 int num_input_streams_; |
178 | 184 |
179 // Track output state change listeners. | 185 // Track output state change listeners. |
180 ObserverList<AudioDeviceListener> output_listeners_; | 186 ObserverList<AudioDeviceListener> output_listeners_; |
181 | 187 |
| 188 // Track ..... |
| 189 ObserverList<StateChangeListener> state_listeners_; |
| 190 |
182 // Thread used to interact with audio streams created by this audio manager. | 191 // Thread used to interact with audio streams created by this audio manager. |
183 base::Thread audio_thread_; | 192 base::Thread audio_thread_; |
184 | 193 |
185 // The task runner of the audio thread this object runs on. Used for internal | 194 // The task runner of the audio thread this object runs on. Used for internal |
186 // tasks which run on the audio thread even after Shutdown() has been started | 195 // tasks which run on the audio thread even after Shutdown() has been started |
187 // and GetTaskRunner() starts returning NULL. | 196 // and GetTaskRunner() starts returning NULL. |
188 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 197 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
189 | 198 |
190 // Map of cached AudioOutputDispatcher instances. Must only be touched | 199 // Map of cached AudioOutputDispatcher instances. Must only be touched |
191 // from the audio thread (no locking). | 200 // from the audio thread (no locking). |
192 AudioOutputDispatchers output_dispatchers_; | 201 AudioOutputDispatchers output_dispatchers_; |
193 | 202 |
194 // Proxy for creating AudioLog objects. | 203 // Proxy for creating AudioLog objects. |
195 AudioLogFactory* const audio_log_factory_; | 204 AudioLogFactory* const audio_log_factory_; |
196 | 205 |
197 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 206 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
198 }; | 207 }; |
199 | 208 |
200 } // namespace media | 209 } // namespace media |
201 | 210 |
202 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 211 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
OLD | NEW |