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

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

Issue 495983002: Improve logging related to start/stop and failure of audio input streams in Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Experimental version of AudioManagerBase logging 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // Only do power monitoring for non-mobile platforms to save resources. 78 // Only do power monitoring for non-mobile platforms to save resources.
79 #if !defined(OS_ANDROID) && !defined(OS_IOS) 79 #if !defined(OS_ANDROID) && !defined(OS_IOS)
80 #define AUDIO_POWER_MONITORING 80 #define AUDIO_POWER_MONITORING
81 #endif 81 #endif
82 82
83 class UserInputMonitor; 83 class UserInputMonitor;
84 84
85 class MEDIA_EXPORT AudioInputController 85 class MEDIA_EXPORT AudioInputController
86 : public base::RefCountedThreadSafe<AudioInputController>, 86 : public base::RefCountedThreadSafe<AudioInputController>,
87 public AudioInputStream::AudioInputCallback { 87 public AudioInputStream::AudioInputCallback,
88 public AudioManager::StateChangeListener {
88 public: 89 public:
89 90
90 // Error codes to make native loggin more clear. These error codes are added 91 // Error codes to make native loggin more clear. These error codes are added
91 // to generic error strings to provide a higher degree of details. 92 // to generic error strings to provide a higher degree of details.
92 // Changing these values can lead to problems when matching native debug 93 // Changing these values can lead to problems when matching native debug
93 // logs with the actual cause of error. 94 // logs with the actual cause of error.
94 enum ErrorCode { 95 enum ErrorCode {
95 // An unspecified error occured. 96 // An unspecified error occured.
96 UNKNOWN_ERROR = 0, 97 UNKNOWN_ERROR = 0,
97 98
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 virtual void SetAutomaticGainControl(bool enabled); 228 virtual void SetAutomaticGainControl(bool enabled);
228 229
229 // AudioInputCallback implementation. Threading details depends on the 230 // AudioInputCallback implementation. Threading details depends on the
230 // device-specific implementation. 231 // device-specific implementation.
231 virtual void OnData(AudioInputStream* stream, 232 virtual void OnData(AudioInputStream* stream,
232 const AudioBus* source, 233 const AudioBus* source,
233 uint32 hardware_delay_bytes, 234 uint32 hardware_delay_bytes,
234 double volume) OVERRIDE; 235 double volume) OVERRIDE;
235 virtual void OnError(AudioInputStream* stream) OVERRIDE; 236 virtual void OnError(AudioInputStream* stream) OVERRIDE;
236 237
238 virtual void OnStateChange(const std::string state) OVERRIDE;
239
237 bool SharedMemoryAndSyncSocketMode() const { return sync_writer_ != NULL; } 240 bool SharedMemoryAndSyncSocketMode() const { return sync_writer_ != NULL; }
238 241
239 protected: 242 protected:
240 friend class base::RefCountedThreadSafe<AudioInputController>; 243 friend class base::RefCountedThreadSafe<AudioInputController>;
241 244
242 // Internal state of the source. 245 // Internal state of the source.
243 enum State { 246 enum State {
244 CREATED, 247 CREATED,
245 RECORDING, 248 RECORDING,
246 CLOSED 249 CLOSED
247 }; 250 };
248 251
249 #if defined(AUDIO_POWER_MONITORING) 252 #if defined(AUDIO_POWER_MONITORING)
250 // Used to log a silence report (see OnData). 253 // Used to log a silence report (see OnData).
251 // Elements in this enum should not be deleted or rearranged; the only 254 // 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 255 // permitted operation is to add new elements before SILENCE_STATE_MAX and
253 // update SILENCE_STATE_MAX. 256 // update SILENCE_STATE_MAX.
254 enum SilenceState { 257 enum SilenceState {
255 SILENCE_STATE_NO_MEASUREMENT = 0, 258 SILENCE_STATE_NO_MEASUREMENT = 0,
256 SILENCE_STATE_ONLY_AUDIO = 1, 259 SILENCE_STATE_ONLY_AUDIO = 1,
257 SILENCE_STATE_ONLY_SILENCE = 2, 260 SILENCE_STATE_ONLY_SILENCE = 2,
258 SILENCE_STATE_AUDIO_AND_SILENCE = 3, 261 SILENCE_STATE_AUDIO_AND_SILENCE = 3,
259 SILENCE_STATE_MAX = SILENCE_STATE_AUDIO_AND_SILENCE 262 SILENCE_STATE_MAX = SILENCE_STATE_AUDIO_AND_SILENCE
260 }; 263 };
261 #endif 264 #endif
262 265
263 AudioInputController(EventHandler* handler, 266 AudioInputController(AudioManager* audio_manager,
267 EventHandler* handler,
264 SyncWriter* sync_writer, 268 SyncWriter* sync_writer,
265 UserInputMonitor* user_input_monitor); 269 UserInputMonitor* user_input_monitor);
266 virtual ~AudioInputController(); 270 virtual ~AudioInputController();
267 271
268 // Methods called on the audio thread (owned by the AudioManager). 272 // Methods called on the audio thread (owned by the AudioManager).
269 void DoCreate(AudioManager* audio_manager, const AudioParameters& params, 273 void DoCreate(const AudioParameters& params, const std::string& device_id);
270 const std::string& device_id);
271 void DoCreateForStream(AudioInputStream* stream_to_control); 274 void DoCreateForStream(AudioInputStream* stream_to_control);
272 void DoRecord(); 275 void DoRecord();
273 void DoClose(); 276 void DoClose();
274 void DoReportError(); 277 void DoReportError();
275 void DoSetVolume(double volume); 278 void DoSetVolume(double volume);
276 void DoSetAutomaticGainControl(bool enabled); 279 void DoSetAutomaticGainControl(bool enabled);
277 void DoOnData(scoped_ptr<AudioBus> data); 280 void DoOnData(scoped_ptr<AudioBus> data);
278 void DoLogAudioLevel(float level_dbfs); 281 void DoLogAudioLevel(float level_dbfs);
279 282
280 // Method to check if we get recorded data after a stream was started, 283 // Method to check if we get recorded data after a stream was started,
(...skipping 17 matching lines...) Expand all
298 // Gives access to the task runner of the creating thread. 301 // Gives access to the task runner of the creating thread.
299 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_; 302 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_;
300 303
301 // The task runner of audio-manager thread that this object runs on. 304 // The task runner of audio-manager thread that this object runs on.
302 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 305 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
303 306
304 // Contains the AudioInputController::EventHandler which receives state 307 // Contains the AudioInputController::EventHandler which receives state
305 // notifications from this class. 308 // notifications from this class.
306 EventHandler* handler_; 309 EventHandler* handler_;
307 310
311 media::AudioManager* audio_manager_;
no longer working on chromium 2014/08/25 08:20:05 nit, media::AudioManager* const
henrika (OOO until Aug 14) 2014/08/25 12:47:44 const media::AudioManager* audio_manager_ does not
312
308 // Pointer to the audio input stream object. 313 // Pointer to the audio input stream object.
309 AudioInputStream* stream_; 314 AudioInputStream* stream_;
310 315
311 // |no_data_timer_| is used to call OnError() when we stop receiving 316 // |no_data_timer_| is used to call OnError() when we stop receiving
312 // OnData() calls. This can occur when an audio input device is unplugged 317 // OnData() calls. This can occur when an audio input device is unplugged
313 // whilst recording on Windows. 318 // whilst recording on Windows.
314 // See http://crbug.com/79936 for details. 319 // See http://crbug.com/79936 for details.
315 // This member is only touched by the audio thread. 320 // This member is only touched by the audio thread.
316 scoped_ptr<base::Timer> no_data_timer_; 321 scoped_ptr<base::Timer> no_data_timer_;
317 322
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 #endif 355 #endif
351 356
352 size_t prev_key_down_count_; 357 size_t prev_key_down_count_;
353 358
354 DISALLOW_COPY_AND_ASSIGN(AudioInputController); 359 DISALLOW_COPY_AND_ASSIGN(AudioInputController);
355 }; 360 };
356 361
357 } // namespace media 362 } // namespace media
358 363
359 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 364 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698