From 1a8d01dcec084ec94daf7f8adf5e7a25a66a02f6 Mon Sep 17 00:00:00 2001 From: "phoglund@chromium.org" Date: Thu, 15 Aug 2013 11:11:35 +0000 Subject: Revert 217768 "Adding key press detection in the browser process." > Adding key press detection in the browser process. > It works like this on the browser side: > A new object KeyPressMonitor is created on BrowserMainLoop and passed to AudioInputRendererHost to pass to AudioInputController. > AudioInputController::DoRecord calls KeyPressMonitor::AddKeyPressListener --> KeyPressMonitor listens to system key events through UserInputMonitor(only implemented on Linux) --> AudioInputController::OnKeyPressed is called and sets key_pressed_ --> When AudioInputController::OnData called, it writes key_pressed_ to shared memory along with the audio data buffer. > On the renderer side a new param "key_pressed" is added through the code path of passing the flag to the webrtc voice engine. > This CL includes all these changes except the implementation of UserInputMonitor for Windows and Mac. The impl of UserInputMonitor is mostly copied from remoting/host/local_input_monitor_linux.cc > > > BUG= > > Review URL: https://chromiumcodereview.appspot.com/21183002 TBR=jiayl@chromium.org Review URL: https://codereview.chromium.org/22871007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217774 0039d316-1c4b-4281-b951-d872f2087c98 --- media/audio/audio_input_controller.cc | 53 +++++++++++------------------------ 1 file changed, 16 insertions(+), 37 deletions(-) (limited to 'media/audio/audio_input_controller.cc') diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc index f7747b9..31e137e 100644 --- a/media/audio/audio_input_controller.cc +++ b/media/audio/audio_input_controller.cc @@ -36,17 +36,14 @@ namespace media { AudioInputController::Factory* AudioInputController::factory_ = NULL; AudioInputController::AudioInputController(EventHandler* handler, - SyncWriter* sync_writer, - UserInputMonitor* user_input_monitor) + SyncWriter* sync_writer) : creator_loop_(base::MessageLoopProxy::current()), handler_(handler), stream_(NULL), data_is_active_(false), state_(kEmpty), sync_writer_(sync_writer), - max_volume_(0.0), - user_input_monitor_(user_input_monitor), - key_pressed_(false) { + max_volume_(0.0) { DCHECK(creator_loop_.get()); } @@ -59,19 +56,17 @@ scoped_refptr AudioInputController::Create( AudioManager* audio_manager, EventHandler* event_handler, const AudioParameters& params, - const std::string& device_id, - UserInputMonitor* user_input_monitor) { + const std::string& device_id) { DCHECK(audio_manager); if (!params.IsValid() || (params.channels() > kMaxInputChannels)) return NULL; - if (factory_) { - return factory_->Create( - audio_manager, event_handler, params, user_input_monitor); - } - scoped_refptr controller( - new AudioInputController(event_handler, NULL, user_input_monitor)); + if (factory_) + return factory_->Create(audio_manager, event_handler, params); + + scoped_refptr controller(new AudioInputController( + event_handler, NULL)); controller->message_loop_ = audio_manager->GetMessageLoop(); @@ -92,8 +87,7 @@ scoped_refptr AudioInputController::CreateLowLatency( EventHandler* event_handler, const AudioParameters& params, const std::string& device_id, - SyncWriter* sync_writer, - UserInputMonitor* user_input_monitor) { + SyncWriter* sync_writer) { DCHECK(audio_manager); DCHECK(sync_writer); @@ -102,8 +96,8 @@ scoped_refptr AudioInputController::CreateLowLatency( // Create the AudioInputController object and ensure that it runs on // the audio-manager thread. - scoped_refptr controller( - new AudioInputController(event_handler, sync_writer, user_input_monitor)); + scoped_refptr controller(new AudioInputController( + event_handler, sync_writer)); controller->message_loop_ = audio_manager->GetMessageLoop(); // Create and open a new audio input stream from the existing @@ -122,15 +116,14 @@ scoped_refptr AudioInputController::CreateForStream( const scoped_refptr& message_loop, EventHandler* event_handler, AudioInputStream* stream, - SyncWriter* sync_writer, - UserInputMonitor* user_input_monitor) { + SyncWriter* sync_writer) { DCHECK(sync_writer); DCHECK(stream); // Create the AudioInputController object and ensure that it runs on // the audio-manager thread. - scoped_refptr controller( - new AudioInputController(event_handler, sync_writer, user_input_monitor)); + scoped_refptr controller(new AudioInputController( + event_handler, sync_writer)); controller->message_loop_ = message_loop; // TODO(miu): See TODO at top of file. Until that's resolved, we need to @@ -240,9 +233,6 @@ void AudioInputController::DoRecord() { stream_->Start(this); handler_->OnRecording(this); - - if (user_input_monitor_) - user_input_monitor_->AddKeyStrokeListener(this); } void AudioInputController::DoClose() { @@ -261,9 +251,6 @@ void AudioInputController::DoClose() { } state_ = kClosed; - - if (user_input_monitor_) - user_input_monitor_->RemoveKeyStrokeListener(this); } } @@ -333,13 +320,10 @@ void AudioInputController::DoCheckForNoData() { void AudioInputController::OnData(AudioInputStream* stream, const uint8* data, uint32 size, uint32 hardware_delay_bytes, double volume) { - bool key_pressed = false; { base::AutoLock auto_lock(lock_); if (state_ != kRecording) return; - - std::swap(key_pressed, key_pressed_); } // Mark data as active to ensure that the periodic calls to @@ -348,7 +332,7 @@ void AudioInputController::OnData(AudioInputStream* stream, const uint8* data, // Use SyncSocket if we are in a low-latency mode. if (LowLatencyMode()) { - sync_writer_->Write(data, size, volume, key_pressed); + sync_writer_->Write(data, size, volume); sync_writer_->UpdateRecordedBytes(hardware_delay_bytes); return; } @@ -369,13 +353,8 @@ void AudioInputController::OnError(AudioInputStream* stream) { &AudioInputController::DoReportError, this)); } -void AudioInputController::OnKeyStroke() { - base::AutoLock auto_lock(lock_); - key_pressed_ = true; -} - void AudioInputController::DoStopCloseAndClearStream( - base::WaitableEvent* done) { + base::WaitableEvent *done) { DCHECK(message_loop_->BelongsToCurrentThread()); // Allow calling unconditionally and bail if we don't have a stream to close. -- cgit v1.1