Skip to content

Commit

Permalink
Merge pull request #628 from rjonkman/patch-1
Browse files Browse the repository at this point in the history
Reduce chance of usbMIDI.send_now() causing duplicate MIDI packet
  • Loading branch information
PaulStoffregen authored Nov 18, 2021
2 parents 5c64fdc + 3c27151 commit b41aae9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions teensy3/usb_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,14 @@ void usb_midi_send_sysex_add_term_bytes(const uint8_t *data, uint32_t length, ui

void usb_midi_flush_output(void)
{
if (tx_noautoflush == 0 && tx_packet && tx_packet->index > 0) {
tx_packet->len = tx_packet->index * 4;
usb_tx(MIDI_TX_ENDPOINT, tx_packet);
tx_packet = NULL;
if (tx_noautoflush == 0) {
tx_noautoflush = 1;
if (tx_packet && tx_packet->index > 0) {
tx_packet->len = tx_packet->index * 4;
usb_tx(MIDI_TX_ENDPOINT, tx_packet);
tx_packet = NULL;
}
tx_noautoflush = 0;
}
}

Expand Down

0 comments on commit b41aae9

Please sign in to comment.