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

Unified Diff: media/audio/audio_input_controller.cc

Issue 22801007: Adds the UserInputMonitor implementation for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/audio_input_controller.cc
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc
index f7747b9d37fb77b948b34e0daf2e3a8407905f56..2899c79bd6071fdd250c59fcf947dd86f47265de 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -9,6 +9,10 @@
#include "media/base/limits.h"
#include "media/base/scoped_histogram_timer.h"
+#if defined(OS_MACOSX)
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+
namespace {
const int kMaxInputChannels = 2;
@@ -46,6 +50,7 @@ AudioInputController::AudioInputController(EventHandler* handler,
sync_writer_(sync_writer),
max_volume_(0.0),
user_input_monitor_(user_input_monitor),
+ prev_key_down_count_(0),
key_pressed_(false) {
DCHECK(creator_loop_.get());
}
@@ -241,6 +246,11 @@ void AudioInputController::DoRecord() {
stream_->Start(this);
handler_->OnRecording(this);
+#if defined(OS_MACOSX)
+ prev_key_down_count_ = CGEventSourceCounterForEventType(
+ kCGEventSourceStateHIDSystemState, kCGEventKeyDown);
+#endif // defined(OS_MACOSX)
+
if (user_input_monitor_)
user_input_monitor_->AddKeyStrokeListener(this);
}
@@ -342,6 +352,15 @@ void AudioInputController::OnData(AudioInputStream* stream, const uint8* data,
std::swap(key_pressed, key_pressed_);
}
+ #if defined(OS_MACOSX)
Robert Sesek 2013/08/22 20:45:16 nit: #if should not be indented
+ uint32_t current_count = CGEventSourceCounterForEventType(
+ kCGEventSourceStateHIDSystemState, kCGEventKeyDown);
+ if (current_count != prev_key_down_count_) {
+ key_pressed = true;
+ }
+ prev_key_down_count_ = current_count;
+ #endif // defined(OS_MACOSX)
+
// Mark data as active to ensure that the periodic calls to
// DoCheckForNoData() does not report an error to the event handler.
SetDataIsActive(true);
« media/audio/audio_input_controller.h ('K') | « media/audio/audio_input_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698