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

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

Issue 1272223003: Implement writing mic audio input data to file for debugging purposes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 3 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
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"
11 #include "base/files/file.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
14 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
17 #include "media/audio/audio_io.h" 18 #include "media/audio/audio_io.h"
18 #include "media/audio/audio_manager_base.h" 19 #include "media/audio/audio_manager_base.h"
19 #include "media/audio/audio_parameters.h" 20 #include "media/audio/audio_parameters.h"
20 #include "media/base/audio_bus.h" 21 #include "media/base/audio_bus.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // audio thread, the controller must not add or release references to the 73 // audio thread, the controller must not add or release references to the
73 // AudioManager or itself (since it in turn holds a reference to the manager). 74 // AudioManager or itself (since it in turn holds a reference to the manager).
74 // 75 //
75 namespace media { 76 namespace media {
76 77
77 // Only do power monitoring for non-mobile platforms to save resources. 78 // Only do power monitoring for non-mobile platforms to save resources.
78 #if !defined(OS_ANDROID) && !defined(OS_IOS) 79 #if !defined(OS_ANDROID) && !defined(OS_IOS)
79 #define AUDIO_POWER_MONITORING 80 #define AUDIO_POWER_MONITORING
80 #endif 81 #endif
81 82
83 class AudioInputWriter;
82 class UserInputMonitor; 84 class UserInputMonitor;
83 85
84 class MEDIA_EXPORT AudioInputController 86 class MEDIA_EXPORT AudioInputController
85 : public base::RefCountedThreadSafe<AudioInputController>, 87 : public base::RefCountedThreadSafe<AudioInputController>,
86 public AudioInputStream::AudioInputCallback { 88 public AudioInputStream::AudioInputCallback {
87 public: 89 public:
88 90
89 // 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
90 // to generic error strings to provide a higher degree of details. 92 // to generic error strings to provide a higher degree of details.
91 // Changing these values can lead to problems when matching native debug 93 // Changing these values can lead to problems when matching native debug
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // AudioInputCallback implementation. Threading details depends on the 224 // AudioInputCallback implementation. Threading details depends on the
223 // device-specific implementation. 225 // device-specific implementation.
224 void OnData(AudioInputStream* stream, 226 void OnData(AudioInputStream* stream,
225 const AudioBus* source, 227 const AudioBus* source,
226 uint32 hardware_delay_bytes, 228 uint32 hardware_delay_bytes,
227 double volume) override; 229 double volume) override;
228 void OnError(AudioInputStream* stream) override; 230 void OnError(AudioInputStream* stream) override;
229 231
230 bool SharedMemoryAndSyncSocketMode() const { return sync_writer_ != NULL; } 232 bool SharedMemoryAndSyncSocketMode() const { return sync_writer_ != NULL; }
231 233
234 // Enable debug recording of audio input.
235 void EnableDebugRecording(AudioInputWriter* input_writer);
236
237 // Disbale debug recording of audio input. Must be called before owner of
238 // |input_writer| deletes it.
239 void DisableDebugRecording(const base::Closure& callback);
240
232 protected: 241 protected:
233 friend class base::RefCountedThreadSafe<AudioInputController>; 242 friend class base::RefCountedThreadSafe<AudioInputController>;
234 243
235 // Internal state of the source. 244 // Internal state of the source.
236 enum State { 245 enum State {
237 CREATED, 246 CREATED,
238 RECORDING, 247 RECORDING,
239 CLOSED 248 CLOSED
240 }; 249 };
241 250
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 305
297 #if defined(AUDIO_POWER_MONITORING) 306 #if defined(AUDIO_POWER_MONITORING)
298 // Updates the silence state, see enum SilenceState above for state 307 // Updates the silence state, see enum SilenceState above for state
299 // transitions. 308 // transitions.
300 void UpdateSilenceState(bool silence); 309 void UpdateSilenceState(bool silence);
301 310
302 // Logs the silence state as UMA stat. 311 // Logs the silence state as UMA stat.
303 void LogSilenceState(SilenceState value); 312 void LogSilenceState(SilenceState value);
304 #endif 313 #endif
305 314
315 // Enable and disable debug recording of audio input. Called on the audio
316 // thread.
317 void DoEnableDebugRecording(AudioInputWriter* input_writer);
318 void DoDisableDebugRecording();
319
320 // Called on the audio thread.
321 void WriteInputDataForDebugging(scoped_ptr<AudioBus> data);
322
306 // Gives access to the task runner of the creating thread. 323 // Gives access to the task runner of the creating thread.
307 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_; 324 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_;
308 325
309 // The task runner of audio-manager thread that this object runs on. 326 // The task runner of audio-manager thread that this object runs on.
310 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 327 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
311 328
312 // Contains the AudioInputController::EventHandler which receives state 329 // Contains the AudioInputController::EventHandler which receives state
313 // notifications from this class. 330 // notifications from this class.
314 EventHandler* handler_; 331 EventHandler* handler_;
315 332
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 376
360 // The silence report sent as UMA stat at the end of a session. 377 // The silence report sent as UMA stat at the end of a session.
361 SilenceState silence_state_; 378 SilenceState silence_state_;
362 #endif 379 #endif
363 380
364 size_t prev_key_down_count_; 381 size_t prev_key_down_count_;
365 382
366 // Time when a low-latency stream is created. 383 // Time when a low-latency stream is created.
367 base::TimeTicks low_latency_create_time_; 384 base::TimeTicks low_latency_create_time_;
368 385
386 // Used for audio debug recordings. Accessed on audio thread.
387 AudioInputWriter* input_writer_;
388
369 DISALLOW_COPY_AND_ASSIGN(AudioInputController); 389 DISALLOW_COPY_AND_ASSIGN(AudioInputController);
370 }; 390 };
371 391
372 } // namespace media 392 } // namespace media
373 393
374 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 394 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « content/renderer/media/aec_dump_message_filter.cc ('k') | media/audio/audio_input_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698