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_INPUT_CONTROLLER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 // Sets the factory used by the static method Create(). AudioInputController | 157 // Sets the factory used by the static method Create(). AudioInputController |
158 // does not take ownership of |factory|. A value of NULL results in an | 158 // does not take ownership of |factory|. A value of NULL results in an |
159 // AudioInputController being created directly. | 159 // AudioInputController being created directly. |
160 static void set_factory_for_testing(Factory* factory) { factory_ = factory; } | 160 static void set_factory_for_testing(Factory* factory) { factory_ = factory; } |
161 AudioInputStream* stream_for_testing() { return stream_; } | 161 AudioInputStream* stream_for_testing() { return stream_; } |
162 | 162 |
163 // The audio device will be created on the audio thread, and when that is | 163 // The audio device will be created on the audio thread, and when that is |
164 // done, the event handler will receive an OnCreated() call from that same | 164 // done, the event handler will receive an OnCreated() call from that same |
165 // thread. |user_input_monitor| is used for typing detection and can be NULL. | 165 // thread. |user_input_monitor| is used for typing detection and can be NULL. |
166 // |file_task_runner| is used for debug recordings. | |
167 // TODO(grunell): Move handling of debug recording to AudioManager. | 166 // TODO(grunell): Move handling of debug recording to AudioManager. |
168 static scoped_refptr<AudioInputController> Create( | 167 static scoped_refptr<AudioInputController> Create( |
169 AudioManager* audio_manager, | 168 AudioManager* audio_manager, |
170 EventHandler* event_handler, | 169 EventHandler* event_handler, |
171 SyncWriter* sync_writer, | 170 SyncWriter* sync_writer, |
172 UserInputMonitor* user_input_monitor, | 171 UserInputMonitor* user_input_monitor, |
173 const AudioParameters& params, | 172 const AudioParameters& params, |
174 const std::string& device_id, | 173 const std::string& device_id, |
175 // External synchronous writer for audio controller. | 174 // External synchronous writer for audio controller. |
176 bool agc_is_enabled, | 175 bool agc_is_enabled); |
177 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); | |
178 | 176 |
179 // Factory method for creating an AudioInputController with an existing | 177 // Factory method for creating an AudioInputController with an existing |
180 // |stream|. The stream will be opened on the audio thread, and when that is | 178 // |stream|. The stream will be opened on the audio thread, and when that is |
181 // done, the event handler will receive an OnCreated() call from that same | 179 // done, the event handler will receive an OnCreated() call from that same |
182 // thread. |user_input_monitor| is used for typing detection and can be NULL. | 180 // thread. |user_input_monitor| is used for typing detection and can be NULL. |
183 // |file_task_runner| and |params| are used for debug recordings. | 181 // |params| is used for debug recordings. |
184 static scoped_refptr<AudioInputController> CreateForStream( | 182 static scoped_refptr<AudioInputController> CreateForStream( |
185 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 183 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
186 EventHandler* event_handler, | 184 EventHandler* event_handler, |
187 AudioInputStream* stream, | 185 AudioInputStream* stream, |
188 // External synchronous writer for audio controller. | 186 // External synchronous writer for audio controller. |
189 SyncWriter* sync_writer, | 187 SyncWriter* sync_writer, |
190 UserInputMonitor* user_input_monitor, | 188 UserInputMonitor* user_input_monitor, |
191 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, | |
192 const AudioParameters& params); | 189 const AudioParameters& params); |
193 | 190 |
194 // Starts recording using the created audio input stream. | 191 // Starts recording using the created audio input stream. |
195 // This method is called on the creator thread. | 192 // This method is called on the creator thread. |
196 virtual void Record(); | 193 virtual void Record(); |
197 | 194 |
198 // Closes the audio input stream. The state is changed and the resources | 195 // Closes the audio input stream. The state is changed and the resources |
199 // are freed on the audio thread. |closed_task| is then executed on the thread | 196 // are freed on the audio thread. |closed_task| is then executed on the thread |
200 // that called Close(). | 197 // that called Close(). |
201 // Callbacks (EventHandler and SyncWriter) must exist until |closed_task| | 198 // Callbacks (EventHandler and SyncWriter) must exist until |closed_task| |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // SILENCE_STATE_NO_MEASUREMENT | 248 // SILENCE_STATE_NO_MEASUREMENT |
252 enum SilenceState { | 249 enum SilenceState { |
253 SILENCE_STATE_NO_MEASUREMENT = 0, | 250 SILENCE_STATE_NO_MEASUREMENT = 0, |
254 SILENCE_STATE_ONLY_AUDIO = 1, | 251 SILENCE_STATE_ONLY_AUDIO = 1, |
255 SILENCE_STATE_ONLY_SILENCE = 2, | 252 SILENCE_STATE_ONLY_SILENCE = 2, |
256 SILENCE_STATE_AUDIO_AND_SILENCE = 3, | 253 SILENCE_STATE_AUDIO_AND_SILENCE = 3, |
257 SILENCE_STATE_MAX = SILENCE_STATE_AUDIO_AND_SILENCE | 254 SILENCE_STATE_MAX = SILENCE_STATE_AUDIO_AND_SILENCE |
258 }; | 255 }; |
259 #endif | 256 #endif |
260 | 257 |
261 AudioInputController( | 258 AudioInputController(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
262 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 259 EventHandler* handler, |
263 EventHandler* handler, | 260 SyncWriter* sync_writer, |
264 SyncWriter* sync_writer, | 261 UserInputMonitor* user_input_monitor, |
265 UserInputMonitor* user_input_monitor, | 262 const AudioParameters& params, |
266 const AudioParameters& params, | 263 StreamType type); |
267 StreamType type, | |
268 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); | |
269 virtual ~AudioInputController(); | 264 virtual ~AudioInputController(); |
270 | 265 |
271 const scoped_refptr<base::SingleThreadTaskRunner>& GetTaskRunnerForTesting() | 266 const scoped_refptr<base::SingleThreadTaskRunner>& GetTaskRunnerForTesting() |
272 const { | 267 const { |
273 return task_runner_; | 268 return task_runner_; |
274 } | 269 } |
275 | 270 |
276 EventHandler* GetHandlerForTesting() const { return handler_; } | 271 EventHandler* GetHandlerForTesting() const { return handler_; } |
277 | 272 |
278 private: | 273 private: |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // The weak_ptr_factory_ and all outstanding weak pointers, are invalidated | 394 // The weak_ptr_factory_ and all outstanding weak pointers, are invalidated |
400 // at the end of DoClose. | 395 // at the end of DoClose. |
401 base::WeakPtrFactory<AudioInputController> weak_ptr_factory_; | 396 base::WeakPtrFactory<AudioInputController> weak_ptr_factory_; |
402 | 397 |
403 DISALLOW_COPY_AND_ASSIGN(AudioInputController); | 398 DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
404 }; | 399 }; |
405 | 400 |
406 } // namespace media | 401 } // namespace media |
407 | 402 |
408 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 403 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
OLD | NEW |