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

Commit 2dfa6d12 authored by Phil Burk's avatar Phil Burk Committed by Android (Google) Code Review
Browse files

Merge "bluetoothmidiservice: fix timestamp for BLE-MIDI transmitted packets"

parents 397a7d81 94ec584b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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