Minor MIDI profile improvements
v2 cover Minor MIDI profile improvements
Minor improvements that doesn't have any affect in functionality.
Changes from v1:
* Removed SOB from patches.
Felipe F. Tonello (2):
profiles/midi: Add safer buffer setter function profiles/midi: Moved MIDI UUIDs to library header
profiles/midi/libmidi.c | 9 ++++++++- profiles/midi/libmidi.h | 3 +++ profiles/midi/midi.c | 3 --- 3 files changed, 11 insertions(+), 4 deletions(-)
Signature · 1 line
2.11.1
PATCH v2 1/2 profiles/midi: Add safer buffer setter function
This function helper makes buffer operations more consistent and adds boundary check when its available.
--- profiles/midi/libmidi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
profiles/midi/libmidi.c +8 -1
@@ -52,6 +52,13 @@ inline static uint8_t buffer_reverse_get(struct midi_buffer *buffer, size_t i)return buffer->data[buffer->len - (i +1 )]; } +inline static void buffer_reverse_set (struct midi_buffer *buffer,size_t i, +const uint8_t byte) +{ +MIDI_ASSERT (buffer->len > i); + buffer->data[buffer->len - (i +1 )] = byte; +} +inline static size_t parser_get_available_size (struct midi_write_parser *parser) {return parser->stream_size - parser->midi_stream.len;
@@ -314,7 +321,7 @@ static size_t handle_end_of_sysex(struct midi_read_parser *parser, time_low =buffer_reverse_get (&parser->sysex_stream,0 ) &0x7F ;/* Remove timestamp byte */ - parser->sysex_stream.data[parser->sysex_stream.len -1 ] =0xF7 ; +buffer_reverse_set (&parser->sysex_stream,0 ,0xF7 );/* Update event */ update_ev_timestamp (parser, ev, time_low);
Signature · 1 line
2.11.1
PATCH v2 2/2 profiles/midi: Moved MIDI UUIDs to library header
In reply to Felipe F. TonelloThis allows other users of libmidi to consistently use MIDI UUIDs.
--- profiles/midi/libmidi.h | 3 +++ profiles/midi/midi.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)
profiles/midi/libmidi.h +3 -0
@@ -29,6 +29,9 @@#include <stdbool.h> #include <alsa/asoundlib.h> +#define MIDI_UUID "03B80E5A-EDE8-4B33-A751-6CE34EC4C700" +#define MIDI_IO_UUID "7772E5DB-3868-4112-A1A9-F2669D106BF3" +#define MIDI_MAX_TIMESTAMP 8191#define MIDI_MSG_MAX_SIZE 12#define MIDI_SYSEX_MAX_SIZE (4 * 1024)
profiles/midi/midi.c +0 -3
@@ -53,9 +53,6 @@#include "libmidi.h" -#define MIDI_UUID "03B80E5A-EDE8-4B33-A751-6CE34EC4C700" -#define MIDI_IO_UUID "7772E5DB-3868-4112-A1A9-F2669D106BF3" -struct midi {struct btd_device *dev;struct gatt_db *db;
Signature · 1 line
2.11.1
Hi Felipe,
Quoted 9 lines · Felipe F. Tonello
Minor improvements that doesn't have any affect in functionality.
Changes from v1:
* Removed SOB from patches.Felipe F. Tonello (2):
profiles/midi: Add safer buffer setter function profiles/midi: Moved MIDI UUIDs to library header
Quoted 7 lines
profiles/midi/libmidi.c | 9 ++++++++- profiles/midi/libmidi.h | 3 +++ profiles/midi/midi.c | 3 --- 3 files changed, 11 insertions(+), 4 deletions(-)--
2.11.1
Applied, thanks.
Signature · 1 line
Luiz Augusto von Dentz