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

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
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..98461b0250a5d5d1cdd73b1d110fe579ec00316b 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());
}
@@ -334,6 +339,14 @@ void AudioInputController::OnData(AudioInputStream* stream, const uint8* data,
uint32 size, uint32 hardware_delay_bytes,
double volume) {
bool key_pressed = false;
+#if defined(OS_MACOSX)
+ uint32_t current_count = CGEventSourceCounterForEventType(
Mark Mentovai 2013/08/22 18:27:52 I don’t know much about when this thing is called.
jiayl 2013/08/22 18:51:16 Done initialization in DoRecord. I don't think it
+ kCGEventSourceStateHIDSystemState, kCGEventKeyDown);
+ if (current_count > prev_key_down_count_ && prev_key_down_count_ != 0) {
Mark Mentovai 2013/08/22 18:27:52 If you change > to !=, then this handles rollover
jiayl 2013/08/22 18:51:16 Done.
+ key_pressed = true;
+ }
+ prev_key_down_count_ = current_count;
+#else
{
base::AutoLock auto_lock(lock_);
if (state_ != kRecording)
@@ -341,6 +354,7 @@ void AudioInputController::OnData(AudioInputStream* stream, const uint8* data,
std::swap(key_pressed, key_pressed_);
}
+#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.
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698