Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] midi: Fix stall when timestampHigh is zero
@ 2026-12-02 18:01 aparilli
  2026-12-03 12:51 ` [BlueZ] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: aparilli @ 2026-12-02 18:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Alessandro Parilli

From: Alessandro Parilli <nauta@google.com>

append_timestamp_high_maybe() busy-waits until the high 6 bits of the
13-bit millisecond timestamp become non-zero, treating a header byte of
0x80 as invalid. The BLE MIDI specification allows a timestampHigh of 0
(the header is 0b10hhhhhh), and the high bits are 0 for the first 128 ms
of every 8.192 s timestamp period. Any packet started in that window
makes bluetoothd spin in its main loop for up to 128 ms, sending and
reading nothing.

With MIDI clock (24 ppqn) sent to a synth over BLE this shows up every
8.192 s: a btmon capture at 100 BPM (one clock message every 25 ms)
shows the outgoing ATT writes stopping for 135-152 ms each period,
followed by a single packet carrying the 3 clock messages that queued
up. Clock-following devices drift behind each time.

Write the header from the current time once instead. The read side
already handles a timestampHigh of 0.
---
 profiles/midi/libmidi.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c
index 349f5f7..d90f522 100644
--- a/profiles/midi/libmidi.c
+++ b/profiles/midi/libmidi.c
@@ -58,20 +58,18 @@ inline static uint8_t sysex_get(const snd_seq_event_t *ev, size_t i)
 
 inline static void append_timestamp_high_maybe(struct midi_write_parser *parser)
 {
-	uint8_t timestamp_high = 0x80;
-
 	if (midi_write_has_data(parser))
 		return;
 
-	/* Make sure timesampt_high is assigned a non-zero value */
-	do {
-		/* convert µs to ms */
-		parser->rtime = g_get_monotonic_time() / 1000;
-		timestamp_high |= (parser->rtime & 0x1F80) >> 7;
-	} while (timestamp_high == 0x80);
+	/* convert µs to ms */
+	parser->rtime = g_get_monotonic_time() / 1000;
 
-	/* set timestampHigh */
-	buffer_append_byte(&parser->midi_stream, timestamp_high);
+	/*
+	 * set timestampHigh: the header byte is 10hhhhhh and a timestampHigh
+	 * of 0 (header 0x80) is valid.
+	 */
+	buffer_append_byte(&parser->midi_stream,
+				0x80 | ((parser->rtime & 0x1F80) >> 7));
 }
 
 inline static void append_timestamp_low(struct midi_write_parser *parser)
-- 
2.56.1.911.g883d8bcb20-goog


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

* RE: [BlueZ] midi: Fix stall when timestampHigh is zero
  2026-12-02 18:01 [PATCH BlueZ] midi: Fix stall when timestampHigh is zero aparilli
@ 2026-12-03 12:51 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-12-03 12:51 UTC (permalink / raw)
  To: linux-bluetooth, nauta

[-- Attachment #1: Type: text/plain, Size: 1261 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/series/1229807/

---Test result---

Test Summary:
CheckPatch                    PASS      0.40 seconds
GitLint                       PASS      0.28 seconds
BuildEll                      PASS      19.98 seconds
BluezMake                     PASS      308.57 seconds
MakeCheck                     PASS      0.99 seconds
MakeDistcheck                 PASS      146.36 seconds
CheckValgrind                 PASS      154.13 seconds
CheckSmatch                   PASS      313.42 seconds
bluezmakeextell               PASS      99.72 seconds
TestFunctional                FAIL      1260.53 seconds
IncrementalBuild              PASS      310.66 seconds
ScanBuild                     PASS      1185.49 seconds

Details
##############################
Test: TestFunctional - FAIL
Desc: Run test-functional
Output:
FAIL functional.test_bap::test_bass_past_earbuds_transport_acquire[hosts11-vm3]: AssertionError: Failed to acquire: org.bluez.Error.Failed


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

---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2026-12-03 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 18:01 [PATCH BlueZ] midi: Fix stall when timestampHigh is zero aparilli
2026-12-03 12:51 ` [BlueZ] " bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox