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

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

Issue 462813004: Add UMA stats for silence AudioInputController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed to report 4 silence cases. 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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_NO_SILENCE = 1,
257 SILENCE_STATE_ONLY_SILENCE = 2,
258 SILENCE_STATE_PARTIAL_SILENCE = 3,
259 SILENCE_STATE_MAX = SILENCE_STATE_PARTIAL_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 bool enable_nodata_timer); 272 bool enable_nodata_timer);
(...skipping 12 matching lines...) Expand all
271 // Method which ensures that OnError() is triggered when data recording 285 // Method which ensures that OnError() is triggered when data recording
272 // times out. Called on the audio thread. 286 // times out. Called on the audio thread.
273 void DoCheckForNoData(); 287 void DoCheckForNoData();
274 288
275 // Helper method that stops, closes, and NULL:s |*stream_|. 289 // Helper method that stops, closes, and NULL:s |*stream_|.
276 void DoStopCloseAndClearStream(); 290 void DoStopCloseAndClearStream();
277 291
278 void SetDataIsActive(bool enabled); 292 void SetDataIsActive(bool enabled);
279 bool GetDataIsActive(); 293 bool GetDataIsActive();
280 294
295 #if defined(AUDIO_POWER_MONITORING)
296 void LogSilenceState(SilenceState value);
297 #endif
298
281 // Gives access to the task runner of the creating thread. 299 // Gives access to the task runner of the creating thread.
282 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_; 300 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_;
283 301
284 // The task runner of audio-manager thread that this object runs on. 302 // The task runner of audio-manager thread that this object runs on.
285 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 303 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
286 304
287 // Contains the AudioInputController::EventHandler which receives state 305 // Contains the AudioInputController::EventHandler which receives state
288 // notifications from this class. 306 // notifications from this class.
289 EventHandler* handler_; 307 EventHandler* handler_;
290 308
(...skipping 29 matching lines...) Expand all
320 338
321 UserInputMonitor* user_input_monitor_; 339 UserInputMonitor* user_input_monitor_;
322 340
323 #if defined(AUDIO_POWER_MONITORING) 341 #if defined(AUDIO_POWER_MONITORING)
324 // Scans audio samples from OnData() as input to compute audio levels. 342 // Scans audio samples from OnData() as input to compute audio levels.
325 scoped_ptr<AudioPowerMonitor> audio_level_; 343 scoped_ptr<AudioPowerMonitor> audio_level_;
326 344
327 // We need these to be able to feed data to the AudioPowerMonitor. 345 // We need these to be able to feed data to the AudioPowerMonitor.
328 media::AudioParameters audio_params_; 346 media::AudioParameters audio_params_;
329 base::TimeTicks last_audio_level_log_time_; 347 base::TimeTicks last_audio_level_log_time_;
348
349 // The silence report sent as UMA stat at the end of a session.
350 SilenceState silence_state_;
330 #endif 351 #endif
331 352
332 size_t prev_key_down_count_; 353 size_t prev_key_down_count_;
333 354
334 DISALLOW_COPY_AND_ASSIGN(AudioInputController); 355 DISALLOW_COPY_AND_ASSIGN(AudioInputController);
335 }; 356 };
336 357
337 } // namespace media 358 } // namespace media
338 359
339 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 360 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_input_controller.cc » ('j') | media/audio/audio_input_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698