profiles/midi: Fix zero timestampHigh
PATCH v2 1/1 profiles/midi: Fix zero timestampHigh
BLE-MIDI timestampHigh can legitimately be zero. The MIDI parser used timestamp_high == 0 to decide whether it had already consumed the packet header, so packets starting with 0x80 0x80 caused the next running-status payload byte to be consumed as another timestamp header.
Track whether timestampHigh has been read separately from its value so packed MIDI events with zero timestampHigh are parsed correctly.
--- profiles/midi/libmidi.c | 5 ++++- profiles/midi/libmidi.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-)
profiles/midi/libmidi.c +4 -1
@@ -110,6 +110,7 @@ int midi_read_init(struct midi_read_parser *parser) parser->timestamp =0 ; parser->timestamp_low =0 ; parser->timestamp_high =0 ; + parser->timestamp_high_set = false; parser->sysex_stream.data =malloc (MIDI_SYSEX_MAX_SIZE );if (!parser->sysex_stream.data)
@@ -355,8 +356,10 @@ size_t midi_read_raw(struct midi_read_parser *parser, const uint8_t *data,size_t i =0 ;bool err = false; -if (parser->timestamp_high ==0 ) +if (!parser->timestamp_high_set) { parser->timestamp_high = data[i++] &0x3F ; + parser->timestamp_high_set = true; + }snd_midi_event_reset_encode (parser->midi_ev);
profiles/midi/libmidi.h +2 -0
@@ -83,6 +83,7 @@ struct midi_read_parser {int16_t timestamp;/* last MIDI-BLE timestamp */ int8_t timestamp_low;/* MIDI-BLE timestampLow from the current packet */ int8_t timestamp_high;/* MIDI-BLE timestampHigh from the current packet */ +bool timestamp_high_set;/* timestampHigh read */ struct midi_buffer sysex_stream;/* SysEx stream */ snd_midi_event_t *midi_ev;/* midi<->seq event */ };
@@ -100,6 +101,7 @@ static inline void midi_read_reset(struct midi_read_parser *parser) parser->rstatus =0 ; parser->timestamp_low =0 ; parser->timestamp_high =0 ; + parser->timestamp_high_set = false; }/* Parses raw BLE-MIDI messages and populates a sequencer event representing the
Signature · 1 line
2.54.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1117539
---Test result---
Test Summary:
CheckPatch PASS 0.77 seconds GitLint PASS 0.59 seconds BuildEll PASS 21.11 seconds BluezMake PASS 552.10 seconds MakeCheck PASS 1.26 seconds MakeDistcheck PASS 160.30 seconds CheckValgrind PASS 155.74 seconds CheckSmatch PASS 310.72 seconds bluezmakeextell PASS 102.50 seconds IncrementalBuild PASS 548.81 seconds ScanBuild PASS 975.14 seconds
https://github.com/bluez/bluez/pull/2256
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Sat, 27 Jun 2026 15:44:44 -0700 you wrote:
BLE-MIDI timestampHigh can legitimately be zero. The MIDI parser used
timestamp_high== 0 to decide whether it had already consumed the packet header, so packets starting with0x800x80caused the next running-status payload byte to be consumed as another timestamp header.Track whether timestampHigh has been read separately from its value so packed MIDI events with zero timestampHigh are parsed correctly.
[...]
Here is the summary with links:
- [BlueZ,v2] profiles/midi: Fix zero timestampHigh
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=220f102c8db9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html