summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2015-07-30 21:28:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-30 21:28:17 +0000
commit8f5228afe671b5e80fab4d1c55452ad6c83ef4f1 (patch)
treea5509046014d783db4d0eb06574ae8f98df022b4
parent2f1a08e601f4fa24e589fc61ea38f80eb264a8f4 (diff)
parent6456a65afed66819b73df7eb605037402b91fc3f (diff)
downloadframeworks_base-8f5228afe671b5e80fab4d1c55452ad6c83ef4f1.zip
frameworks_base-8f5228afe671b5e80fab4d1c55452ad6c83ef4f1.tar.gz
frameworks_base-8f5228afe671b5e80fab4d1c55452ad6c83ef4f1.tar.bz2
Merge "UsbMidiDevice: add timestamps for input events" into mnc-dev
-rw-r--r--services/usb/java/com/android/server/usb/UsbMidiDevice.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbMidiDevice.java b/services/usb/java/com/android/server/usb/UsbMidiDevice.java
index 97bf505..38ede87 100644
--- a/services/usb/java/com/android/server/usb/UsbMidiDevice.java
+++ b/services/usb/java/com/android/server/usb/UsbMidiDevice.java
@@ -128,7 +128,7 @@ public final class UsbMidiDevice implements Closeable {
mReceiver = receiver;
}
}
-
+
public static UsbMidiDevice create(Context context, Bundle properties, int card, int device) {
// FIXME - support devices with different number of input and output ports
int subDeviceCount = nativeGetSubdeviceCount(card, device);
@@ -203,6 +203,8 @@ public final class UsbMidiDevice implements Closeable {
byte[] buffer = new byte[BUFFER_SIZE];
try {
while (true) {
+ // Record time of event immediately after waking.
+ long timestamp = System.nanoTime();
synchronized (mLock) {
if (!mIsOpen) break;
@@ -215,14 +217,14 @@ public final class UsbMidiDevice implements Closeable {
} else if ((pfd.revents & OsConstants.POLLIN) != 0) {
// clear readable flag
pfd.revents = 0;
-
+
if (index == mInputStreams.length - 1) {
// last file descriptor is used only for unblocking Os.poll()
break;
}
int count = mInputStreams[index].read(buffer);
- outputReceivers[index].send(buffer, 0, count);
+ outputReceivers[index].send(buffer, 0, count, timestamp);
}
}
}