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 <string> | 8 #include <string> |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 protected: | 239 protected: |
240 friend class base::RefCountedThreadSafe<AudioInputController>; | 240 friend class base::RefCountedThreadSafe<AudioInputController>; |
241 | 241 |
242 // Internal state of the source. | 242 // Internal state of the source. |
243 enum State { | 243 enum State { |
244 CREATED, | 244 CREATED, |
245 RECORDING, | 245 RECORDING, |
246 CLOSED | 246 CLOSED |
247 }; | 247 }; |
248 | 248 |
| 249 #if defined(AUDIO_POWER_MONITORING) |
| 250 // Used to log a silence report (see OnData). |
| 251 // Elements in this enum should not be deleted or rearranged; the only |
| 252 // permitted operation is to add new elements before SILENCE_STATE_MAX and |
| 253 // update SILENCE_STATE_MAX. |
| 254 enum SilenceState { |
| 255 SILENCE_STATE_NO_MEASUREMENT = 0, |
| 256 SILENCE_STATE_ONLY_AUDIO = 1, |
| 257 SILENCE_STATE_ONLY_SILENCE = 2, |
| 258 SILENCE_STATE_AUDIO_AND_SILENCE = 3, |
| 259 SILENCE_STATE_MAX = SILENCE_STATE_AUDIO_AND_SILENCE |
| 260 }; |
| 261 #endif |
| 262 |
249 AudioInputController(EventHandler* handler, | 263 AudioInputController(EventHandler* handler, |
250 SyncWriter* sync_writer, | 264 SyncWriter* sync_writer, |
251 UserInputMonitor* user_input_monitor); | 265 UserInputMonitor* user_input_monitor); |
252 virtual ~AudioInputController(); | 266 virtual ~AudioInputController(); |
253 | 267 |
254 // Methods called on the audio thread (owned by the AudioManager). | 268 // Methods called on the audio thread (owned by the AudioManager). |
255 void DoCreate(AudioManager* audio_manager, const AudioParameters& params, | 269 void DoCreate(AudioManager* audio_manager, const AudioParameters& params, |
256 const std::string& device_id); | 270 const std::string& device_id); |
257 void DoCreateForStream(AudioInputStream* stream_to_control); | 271 void DoCreateForStream(AudioInputStream* stream_to_control); |
258 void DoRecord(); | 272 void DoRecord(); |
(...skipping 11 matching lines...) Expand all Loading... |
270 // Method which ensures that OnError() is triggered when data recording | 284 // Method which ensures that OnError() is triggered when data recording |
271 // times out. Called on the audio thread. | 285 // times out. Called on the audio thread. |
272 void DoCheckForNoData(); | 286 void DoCheckForNoData(); |
273 | 287 |
274 // Helper method that stops, closes, and NULL:s |*stream_|. | 288 // Helper method that stops, closes, and NULL:s |*stream_|. |
275 void DoStopCloseAndClearStream(); | 289 void DoStopCloseAndClearStream(); |
276 | 290 |
277 void SetDataIsActive(bool enabled); | 291 void SetDataIsActive(bool enabled); |
278 bool GetDataIsActive(); | 292 bool GetDataIsActive(); |
279 | 293 |
| 294 #if defined(AUDIO_POWER_MONITORING) |
| 295 void LogSilenceState(SilenceState value); |
| 296 #endif |
| 297 |
280 // Gives access to the task runner of the creating thread. | 298 // Gives access to the task runner of the creating thread. |
281 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_; | 299 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_; |
282 | 300 |
283 // The task runner of audio-manager thread that this object runs on. | 301 // The task runner of audio-manager thread that this object runs on. |
284 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 302 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
285 | 303 |
286 // Contains the AudioInputController::EventHandler which receives state | 304 // Contains the AudioInputController::EventHandler which receives state |
287 // notifications from this class. | 305 // notifications from this class. |
288 EventHandler* handler_; | 306 EventHandler* handler_; |
289 | 307 |
(...skipping 29 matching lines...) Expand all Loading... |
319 | 337 |
320 UserInputMonitor* user_input_monitor_; | 338 UserInputMonitor* user_input_monitor_; |
321 | 339 |
322 #if defined(AUDIO_POWER_MONITORING) | 340 #if defined(AUDIO_POWER_MONITORING) |
323 // Scans audio samples from OnData() as input to compute audio levels. | 341 // Scans audio samples from OnData() as input to compute audio levels. |
324 scoped_ptr<AudioPowerMonitor> audio_level_; | 342 scoped_ptr<AudioPowerMonitor> audio_level_; |
325 | 343 |
326 // We need these to be able to feed data to the AudioPowerMonitor. | 344 // We need these to be able to feed data to the AudioPowerMonitor. |
327 media::AudioParameters audio_params_; | 345 media::AudioParameters audio_params_; |
328 base::TimeTicks last_audio_level_log_time_; | 346 base::TimeTicks last_audio_level_log_time_; |
| 347 |
| 348 // The silence report sent as UMA stat at the end of a session. |
| 349 SilenceState silence_state_; |
329 #endif | 350 #endif |
330 | 351 |
331 size_t prev_key_down_count_; | 352 size_t prev_key_down_count_; |
332 | 353 |
333 DISALLOW_COPY_AND_ASSIGN(AudioInputController); | 354 DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
334 }; | 355 }; |
335 | 356 |
336 } // namespace media | 357 } // namespace media |
337 | 358 |
338 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 359 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
OLD | NEW |