Diff between b53fef50969b49f7c2a1376a11677817d3bdcf80 and c29241fe129f4a8dbca4adff45eacf9348d6ae2e

Changed Files

File Additions Deletions Status
profiles/midi/libmidi.c +7 -2 modified

Full Patch

diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c
index 7d57e73..cb2787d 100644
--- a/profiles/midi/libmidi.c
+++ b/profiles/midi/libmidi.c
@@ -77,8 +77,13 @@ inline static void append_timestamp_high_maybe(struct midi_write_parser *parser)
 	if (midi_write_has_data(parser))
 		return;
 
-	parser->rtime = g_get_monotonic_time() / 1000; /* convert µs to ms */
-	timestamp_high |= (parser->rtime & 0x1F80) >> 7;
+	/* 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);
+
 	/* set timestampHigh */
 	buffer_append_byte(&parser->midi_stream, timestamp_high);
 }