summaryrefslogtreecommitdiff
path: root/media/packages
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2017-02-21 16:15:33 -0800
committerPhil Burk <philburk@google.com>2017-02-21 16:15:33 -0800
commit94ec584bed85ecead4529789c63421736797f5f0 (patch)
tree5694e342c51a3b6e3e4f3fba39808e20e220abe9 /media/packages
parentdcdaaec8d5bb58b55d59a5759cb393e258c6d8d5 (diff)
bluetoothmidiservice: fix timestamp for BLE-MIDI transmitted packets
Transmitted packets that contained multiple MIDI messages and that did not use running status were missing a timestamp! This CL fixes that bug. Bug: 34708799 Test: a manual test using MidiMatrix is described in the bug report Change-Id: Iddb55e01c60625787c5907fe8e4b202ef1415e59 Signed-off-by: Phil Burk <philburk@google.com>
Diffstat (limited to 'media/packages')
-rw-r--r--media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothPacketEncoder.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothPacketEncoder.java b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothPacketEncoder.java
index 5fb162c09325..8ac6b5674256 100644
--- a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothPacketEncoder.java
+++ b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothPacketEncoder.java
@@ -48,7 +48,7 @@ public class BluetoothPacketEncoder extends PacketEncoder {
private boolean mWritePending;
- private final Object mLock = new Object();
+ private final Object mLock = new Object();
// This receives normalized data from mMidiFramer and accumulates it into a packet buffer
private final MidiReceiver mFramedDataReceiver = new MidiReceiver() {
@@ -60,6 +60,8 @@ public class BluetoothPacketEncoder extends PacketEncoder {
int milliTimestamp = (int)(timestamp / MILLISECOND_NANOS) & MILLISECOND_MASK;
byte status = msg[offset];
boolean isSysExStart = (status == MidiConstants.STATUS_SYSTEM_EXCLUSIVE);
+ // Because of the MidiFramer, if it is not a status byte then it
+ // must be a continuation.
boolean isSysExContinuation = ((status & 0x80) == 0);
int bytesNeeded;
@@ -70,7 +72,9 @@ public class BluetoothPacketEncoder extends PacketEncoder {
bytesNeeded = count;
}
- boolean needsTimestamp = (milliTimestamp != mPacketTimestamp);
+ // Status bytes must be preceded by a timestamp
+ boolean needsTimestamp = (status != mRunningStatus)
+ || (milliTimestamp != mPacketTimestamp);
if (isSysExStart) {
// SysEx start byte must be preceded by a timestamp
needsTimestamp = true;
@@ -78,6 +82,7 @@ public class BluetoothPacketEncoder extends PacketEncoder {
// SysEx continuation packets must not have timestamp byte
needsTimestamp = false;
}
+
if (needsTimestamp) bytesNeeded++; // add one for timestamp byte
if (status == mRunningStatus) bytesNeeded--; // subtract one for status byte