All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] profiles/midi: Fix zero timestampHigh
@ 2026-06-27 17:57 Matthew Cash
  2026-06-27 19:39 ` [BlueZ] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Cash @ 2026-06-27 17:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Matthew Cash

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(-)

diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c
index 6f2914a8c..ef33f7dfd 100644
--- a/profiles/midi/libmidi.c
+++ b/profiles/midi/libmidi.c
@@ -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);
 
diff --git a/profiles/midi/libmidi.h b/profiles/midi/libmidi.h
index 41f522dd4..9d314cc11 100644
--- a/profiles/midi/libmidi.h
+++ b/profiles/midi/libmidi.h
@@ -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 for current packet */
 	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
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [BlueZ] profiles/midi: Fix zero timestampHigh
  2026-06-27 17:57 [PATCH BlueZ] profiles/midi: Fix zero timestampHigh Matthew Cash
@ 2026-06-27 19:39 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-06-27 19:39 UTC (permalink / raw)
  To: linux-bluetooth, matthew

[-- Attachment #1: Type: text/plain, Size: 1927 bytes --]

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=1117512

---Test result---

Test Summary:
CheckPatch                    FAIL      0.87 seconds
GitLint                       PASS      0.48 seconds
BuildEll                      PASS      20.81 seconds
BluezMake                     PASS      557.39 seconds
MakeCheck                     PASS      1.01 seconds
MakeDistcheck                 PASS      159.80 seconds
CheckValgrind                 PASS      159.07 seconds
CheckSmatch                   PASS      313.75 seconds
bluezmakeextell               PASS      104.20 seconds
IncrementalBuild              PASS      554.95 seconds
ScanBuild                     PASS      991.64 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ] profiles/midi: Fix zero timestampHigh
WARNING:LONG_LINE_COMMENT: line length of 84 exceeds 80 columns
#123: FILE: profiles/midi/libmidi.h:86:
+	bool timestamp_high_set;         /* timestampHigh read for current packet */

/github/workspace/src/patch/14648381.patch total: 0 errors, 1 warnings, 32 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/patch/14648381.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.




https://github.com/bluez/bluez/pull/2255

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-27 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-27 17:57 [PATCH BlueZ] profiles/midi: Fix zero timestampHigh Matthew Cash
2026-06-27 19:39 ` [BlueZ] " bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.