Index: media/audio/audio_input_controller.h |
diff --git a/media/audio/audio_input_controller.h b/media/audio/audio_input_controller.h |
index 586d47703a18f01b9f7cc15a8168b1b4bae3f2a2..f2808be095bd0c6182d085118da9ddf049d633f0 100644 |
--- a/media/audio/audio_input_controller.h |
+++ b/media/audio/audio_input_controller.h |
@@ -16,6 +16,7 @@ |
#include "base/timer/timer.h" |
#include "media/audio/audio_io.h" |
#include "media/audio/audio_manager_base.h" |
+#include "media/audio/key_press_monitor.h" |
// An AudioInputController controls an AudioInputStream and records data |
// from this input stream. The two main methods are Record() and Close() and |
@@ -74,7 +75,8 @@ namespace media { |
class MEDIA_EXPORT AudioInputController |
: public base::RefCountedThreadSafe<AudioInputController>, |
- public AudioInputStream::AudioInputCallback { |
+ public AudioInputStream::AudioInputCallback, |
+ public KeyPressMonitor::KeyPressListener { |
public: |
// An event handler that receives events from the AudioInputController. The |
// following methods are all called on the audio thread. |
@@ -102,7 +104,10 @@ class MEDIA_EXPORT AudioInputController |
// Write certain amount of data from |data|. This method returns |
// number of written bytes. |
- virtual uint32 Write(const void* data, uint32 size, double volume) = 0; |
+ virtual uint32 Write(const void* data, |
+ uint32 size, |
+ double volume, |
+ bool key_pressed) = 0; |
// Close this synchronous writer. |
virtual void Close() = 0; |
@@ -112,9 +117,12 @@ class MEDIA_EXPORT AudioInputController |
// to create the AudioInputController. Factory is intended for testing only. |
class Factory { |
public: |
- virtual AudioInputController* Create(AudioManager* audio_manager, |
- EventHandler* event_handler, |
- AudioParameters params) = 0; |
+ virtual AudioInputController* Create( |
+ AudioManager* audio_manager, |
+ EventHandler* event_handler, |
+ AudioParameters params, |
+ KeyPressMonitor* key_press_monitor) = 0; |
+ |
protected: |
virtual ~Factory() {} |
}; |
@@ -127,7 +135,8 @@ class MEDIA_EXPORT AudioInputController |
AudioManager* audio_manager, |
EventHandler* event_handler, |
const AudioParameters& params, |
- const std::string& device_id); |
+ const std::string& device_id, |
+ KeyPressMonitor* key_press_monitor); |
// Sets the factory used by the static method Create(). AudioInputController |
// does not take ownership of |factory|. A value of NULL results in an |
@@ -145,7 +154,8 @@ class MEDIA_EXPORT AudioInputController |
const AudioParameters& params, |
const std::string& device_id, |
// External synchronous writer for audio controller. |
- SyncWriter* sync_writer); |
+ SyncWriter* sync_writer, |
+ KeyPressMonitor* key_press_monitor); |
// Factory method for creating an AudioInputController for low-latency mode, |
// taking ownership of |stream|. The stream will be opened on the audio |
@@ -156,7 +166,8 @@ class MEDIA_EXPORT AudioInputController |
EventHandler* event_handler, |
AudioInputStream* stream, |
// External synchronous writer for audio controller. |
- SyncWriter* sync_writer); |
+ SyncWriter* sync_writer, |
+ KeyPressMonitor* key_press_monitor); |
// Starts recording using the created audio input stream. |
// This method is called on the creator thread. |
@@ -189,6 +200,9 @@ class MEDIA_EXPORT AudioInputController |
bool LowLatencyMode() const { return sync_writer_ != NULL; } |
+ // Impl of KeyPressListener. |
+ virtual void OnKeyPressed() OVERRIDE; |
+ |
protected: |
friend class base::RefCountedThreadSafe<AudioInputController>; |
@@ -201,7 +215,9 @@ class MEDIA_EXPORT AudioInputController |
kError |
}; |
- AudioInputController(EventHandler* handler, SyncWriter* sync_writer); |
+ AudioInputController(EventHandler* handler, |
+ SyncWriter* sync_writer, |
+ KeyPressMonitor* key_press_monitor); |
virtual ~AudioInputController(); |
// Methods called on the audio thread (owned by the AudioManager). |
@@ -266,6 +282,12 @@ class MEDIA_EXPORT AudioInputController |
double max_volume_; |
+ KeyPressMonitor* key_press_monitor_; |
+ |
+ base::Lock key_pressed_lock_; |
+ // True if any key has been pressed after the last OnData call. |
+ bool key_pressed_; |
+ |
DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
}; |