Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2092)

Side by Side Diff: media/audio/audio_input_controller.h

Issue 486633003: Only log audio input silence state UMA stats for low latency mode and if not fake device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review + rebase. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/audio_input_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // thread. |user_input_monitor| is used for typing detection and can be NULL. 184 // thread. |user_input_monitor| is used for typing detection and can be NULL.
185 static scoped_refptr<AudioInputController> CreateLowLatency( 185 static scoped_refptr<AudioInputController> CreateLowLatency(
186 AudioManager* audio_manager, 186 AudioManager* audio_manager,
187 EventHandler* event_handler, 187 EventHandler* event_handler,
188 const AudioParameters& params, 188 const AudioParameters& params,
189 const std::string& device_id, 189 const std::string& device_id,
190 // External synchronous writer for audio controller. 190 // External synchronous writer for audio controller.
191 SyncWriter* sync_writer, 191 SyncWriter* sync_writer,
192 UserInputMonitor* user_input_monitor); 192 UserInputMonitor* user_input_monitor);
193 193
194 // Factory method for creating an AudioInputController for low-latency mode, 194 // Factory method for creating an AudioInputController with an existing
195 // taking ownership of |stream|. The stream will be opened on the audio 195 // |stream| for low-latency mode, taking ownership of |stream|. The stream
196 // thread, and when that is done, the event handler will receive an 196 // will be opened on the audio thread, and when that is done, the event
197 // OnCreated() call from that same thread. |user_input_monitor| is used for 197 // handler will receive an OnCreated() call from that same thread.
198 // typing detection and can be NULL. 198 // |user_input_monitor| is used for typing detection and can be NULL.
199 static scoped_refptr<AudioInputController> CreateForStream( 199 static scoped_refptr<AudioInputController> CreateForStream(
200 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 200 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
201 EventHandler* event_handler, 201 EventHandler* event_handler,
202 AudioInputStream* stream, 202 AudioInputStream* stream,
203 // External synchronous writer for audio controller. 203 // External synchronous writer for audio controller.
204 SyncWriter* sync_writer, 204 SyncWriter* sync_writer,
205 UserInputMonitor* user_input_monitor); 205 UserInputMonitor* user_input_monitor);
206 206
207 // Starts recording using the created audio input stream. 207 // Starts recording using the created audio input stream.
208 // This method is called on the creator thread. 208 // This method is called on the creator thread.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 CREATED, 244 CREATED,
245 RECORDING, 245 RECORDING,
246 CLOSED 246 CLOSED
247 }; 247 };
248 248
249 #if defined(AUDIO_POWER_MONITORING) 249 #if defined(AUDIO_POWER_MONITORING)
250 // Used to log a silence report (see OnData). 250 // Used to log a silence report (see OnData).
251 // Elements in this enum should not be deleted or rearranged; the only 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 252 // permitted operation is to add new elements before SILENCE_STATE_MAX and
253 // update SILENCE_STATE_MAX. 253 // update SILENCE_STATE_MAX.
254 // Possible silence state transitions:
255 // SILENCE_STATE_AUDIO_AND_SILENCE
256 // ^ ^
257 // SILENCE_STATE_ONLY_AUDIO SILENCE_STATE_ONLY_SILENCE
258 // ^ ^
259 // SILENCE_STATE_NO_MEASUREMENT
254 enum SilenceState { 260 enum SilenceState {
255 SILENCE_STATE_NO_MEASUREMENT = 0, 261 SILENCE_STATE_NO_MEASUREMENT = 0,
256 SILENCE_STATE_ONLY_AUDIO = 1, 262 SILENCE_STATE_ONLY_AUDIO = 1,
257 SILENCE_STATE_ONLY_SILENCE = 2, 263 SILENCE_STATE_ONLY_SILENCE = 2,
258 SILENCE_STATE_AUDIO_AND_SILENCE = 3, 264 SILENCE_STATE_AUDIO_AND_SILENCE = 3,
259 SILENCE_STATE_MAX = SILENCE_STATE_AUDIO_AND_SILENCE 265 SILENCE_STATE_MAX = SILENCE_STATE_AUDIO_AND_SILENCE
260 }; 266 };
261 #endif 267 #endif
262 268
263 AudioInputController(EventHandler* handler, 269 AudioInputController(EventHandler* handler,
264 SyncWriter* sync_writer, 270 SyncWriter* sync_writer,
265 UserInputMonitor* user_input_monitor); 271 UserInputMonitor* user_input_monitor);
266 virtual ~AudioInputController(); 272 virtual ~AudioInputController();
267 273
268 // Methods called on the audio thread (owned by the AudioManager). 274 // Methods called on the audio thread (owned by the AudioManager).
269 void DoCreate(AudioManager* audio_manager, const AudioParameters& params, 275 void DoCreate(AudioManager* audio_manager, const AudioParameters& params,
270 const std::string& device_id); 276 const std::string& device_id);
277 void DoCreateForLowLatency(AudioManager* audio_manager,
278 const AudioParameters& params,
279 const std::string& device_id);
271 void DoCreateForStream(AudioInputStream* stream_to_control); 280 void DoCreateForStream(AudioInputStream* stream_to_control);
272 void DoRecord(); 281 void DoRecord();
273 void DoClose(); 282 void DoClose();
274 void DoReportError(); 283 void DoReportError();
275 void DoSetVolume(double volume); 284 void DoSetVolume(double volume);
276 void DoSetAutomaticGainControl(bool enabled); 285 void DoSetAutomaticGainControl(bool enabled);
277 void DoOnData(scoped_ptr<AudioBus> data); 286 void DoOnData(scoped_ptr<AudioBus> data);
278 void DoLogAudioLevel(float level_dbfs); 287 void DoLogAudioLevel(float level_dbfs);
279 288
280 // Method to check if we get recorded data after a stream was started, 289 // Method to check if we get recorded data after a stream was started,
281 // and log the result to UMA. 290 // and log the result to UMA.
282 void FirstCheckForNoData(); 291 void FirstCheckForNoData();
283 292
284 // Method which ensures that OnError() is triggered when data recording 293 // Method which ensures that OnError() is triggered when data recording
285 // times out. Called on the audio thread. 294 // times out. Called on the audio thread.
286 void DoCheckForNoData(); 295 void DoCheckForNoData();
287 296
288 // Helper method that stops, closes, and NULL:s |*stream_|. 297 // Helper method that stops, closes, and NULL:s |*stream_|.
289 void DoStopCloseAndClearStream(); 298 void DoStopCloseAndClearStream();
290 299
291 void SetDataIsActive(bool enabled); 300 void SetDataIsActive(bool enabled);
292 bool GetDataIsActive(); 301 bool GetDataIsActive();
293 302
294 #if defined(AUDIO_POWER_MONITORING) 303 #if defined(AUDIO_POWER_MONITORING)
304 // Updates the silence state, see enum SilenceState above for state
305 // transitions.
306 void UpdateSilenceState(bool silence);
307
308 // Logs the silence state as UMA stat.
295 void LogSilenceState(SilenceState value); 309 void LogSilenceState(SilenceState value);
296 #endif 310 #endif
297 311
298 // Gives access to the task runner of the creating thread. 312 // Gives access to the task runner of the creating thread.
299 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_; 313 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_;
300 314
301 // The task runner of audio-manager thread that this object runs on. 315 // The task runner of audio-manager thread that this object runs on.
302 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 316 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
303 317
304 // Contains the AudioInputController::EventHandler which receives state 318 // Contains the AudioInputController::EventHandler which receives state
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 UserInputMonitor* user_input_monitor_; 352 UserInputMonitor* user_input_monitor_;
339 353
340 #if defined(AUDIO_POWER_MONITORING) 354 #if defined(AUDIO_POWER_MONITORING)
341 // Scans audio samples from OnData() as input to compute audio levels. 355 // Scans audio samples from OnData() as input to compute audio levels.
342 scoped_ptr<AudioPowerMonitor> audio_level_; 356 scoped_ptr<AudioPowerMonitor> audio_level_;
343 357
344 // We need these to be able to feed data to the AudioPowerMonitor. 358 // We need these to be able to feed data to the AudioPowerMonitor.
345 media::AudioParameters audio_params_; 359 media::AudioParameters audio_params_;
346 base::TimeTicks last_audio_level_log_time_; 360 base::TimeTicks last_audio_level_log_time_;
347 361
362 // Whether the silence state should sent as UMA stat.
363 bool log_silence_state_;
364
348 // The silence report sent as UMA stat at the end of a session. 365 // The silence report sent as UMA stat at the end of a session.
349 SilenceState silence_state_; 366 SilenceState silence_state_;
350 #endif 367 #endif
351 368
352 size_t prev_key_down_count_; 369 size_t prev_key_down_count_;
353 370
354 DISALLOW_COPY_AND_ASSIGN(AudioInputController); 371 DISALLOW_COPY_AND_ASSIGN(AudioInputController);
355 }; 372 };
356 373
357 } // namespace media 374 } // namespace media
358 375
359 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 376 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_input_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698