Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6456a65a authored by Phil Burk's avatar Phil Burk
Browse files

UsbMidiDevice: add timestamps for input events



This will improve the accuracy of recorded MIDI performances.

Bug: 22801515
Change-Id: Ib78bc929224f2f27938c83a815eaa62f6b5f9560
Signed-off-by: default avatarPhil Burk <philburk@google.com>
parent b83b5fa6
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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;

@@ -222,7 +224,7 @@ public final class UsbMidiDevice implements Closeable {
                                    }

                                    int count = mInputStreams[index].read(buffer);
                                    outputReceivers[index].send(buffer, 0, count);
                                    outputReceivers[index].send(buffer, 0, count, timestamp);
                                }
                            }
                        }