Merge "USB MIDI: Fix incorrect timestamps" into udc-dev

This commit is contained in:
TreeHugger Robot
2023-02-22 19:45:15 +00:00
committed by Android (Google) Code Review

View File

@@ -379,8 +379,6 @@ public final class UsbDirectMidiDevice implements Closeable {
Log.w(TAG, "input thread interrupted"); Log.w(TAG, "input thread interrupted");
break; break;
} }
// Record time of event immediately after waking.
long timestamp = System.nanoTime();
final ByteBuffer byteBuffer = ByteBuffer.wrap(inputBuffer); final ByteBuffer byteBuffer = ByteBuffer.wrap(inputBuffer);
if (!request.queue(byteBuffer)) { if (!request.queue(byteBuffer)) {
Log.w(TAG, "Cannot queue request"); Log.w(TAG, "Cannot queue request");
@@ -396,6 +394,9 @@ public final class UsbDirectMidiDevice implements Closeable {
continue; continue;
} }
// Record time of event after receiving response.
long timestamp = System.nanoTime();
int bytesRead = byteBuffer.position(); int bytesRead = byteBuffer.position();
if (bytesRead > 0) { if (bytesRead > 0) {