diff --git a/lib_xua/src/midi/midioutparse.h b/lib_xua/src/midi/midioutparse.h index d1dc5fa6..356d4190 100644 --- a/lib_xua/src/midi/midioutparse.h +++ b/lib_xua/src/midi/midioutparse.h @@ -1,8 +1,11 @@ -// Copyright 2011-2021 XMOS LIMITED. +// Copyright 2011-2024 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. #ifndef MIDIOUTPARSE_XH #define MIDIOUTPARSE_XH +#warning MAYBE A SYSEX START AND FINISH IS SAFEST FOR NULL? +#define MIDI_OUT_NULL_MESSAGE 0x00000000 // midi_out_parse will return a size of 0 for this invalid message/event + {unsigned, unsigned, unsigned, unsigned} midi_out_parse(unsigned event); #endif diff --git a/lib_xua/src/midi/queue.h b/lib_xua/src/midi/queue.h index 01287ddb..6576a070 100644 --- a/lib_xua/src/midi/queue.h +++ b/lib_xua/src/midi/queue.h @@ -3,6 +3,8 @@ #ifndef QUEUE_H_ #define QUEUE_H_ +#include "midioutparse.h" + #define assert(x) asm("ecallf %0"::"r"(x)); #ifndef MIDI_ENABLE_ASSERTS @@ -48,10 +50,11 @@ inline void queue_push_word(queue_t &q, unsigned array[], unsigned data) assert(0); } else { // Drop message + return; } - } else { - array[q.wrptr++ & q.mask] = data; } + + array[q.wrptr++ & q.mask] = data; } inline unsigned queue_pop_word(queue_t &q, unsigned array[]) { @@ -59,11 +62,11 @@ inline unsigned queue_pop_word(queue_t &q, unsigned array[]) { if(MIDI_ENABLE_ASSERTS){ assert(0); } else { - return 0x00000000; // midi_out_parse will return a size of 0 for this message/event + return MIDI_OUT_NULL_MESSAGE; } - } else { - return array[q.rdptr++ & q.mask]; } + + return array[q.rdptr++ & q.mask]; } diff --git a/lib_xua/src/midi/queue.xc b/lib_xua/src/midi/queue.xc index b88ce469..d79e7d68 100644 --- a/lib_xua/src/midi/queue.xc +++ b/lib_xua/src/midi/queue.xc @@ -1,4 +1,4 @@ -// Copyright 2013-2021 XMOS LIMITED. +// Copyright 2013-2024 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. #include "queue.h" diff --git a/tests/test_midi_tx.py b/tests/test_midi_tx.py index c9247d38..5b6cfd03 100644 --- a/tests/test_midi_tx.py +++ b/tests/test_midi_tx.py @@ -27,11 +27,6 @@ def test_tx(capfd, config, build_midi): [0x90, 60, 81], # Note on [0x80, 60, 81]] # Note off - # midi_commands = [ - # [0x90, 60, 81], # Note on - # [0x80, 60, 81]] # Note off - - # midi_command_expected = midi_commands[1:] # should skip invalid first message # Make a 1D list from the 2D list midi_command_expected = [[item for row in midi_commands for item in row]]