Skip to content

Commit

Permalink
Check USB connection status while writing
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Oct 27, 2024
1 parent b392bde commit c22d781
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/MIDI_Interfaces/USBMIDI/LowLevel/BulkTX.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ void BulkTX<Derived, MessageTypeT, MaxPacketSizeV>::write(
return;
}
const uint32_t *end = msgs + num_msgs;
while (msgs != end) msgs += write_impl(msgs, end - msgs);
while (msgs != end) {
auto sent = write_impl(msgs, end - msgs);
if (sent == 0 && !wait_connect()) {
writing.error.fetch_add(end - msgs, mo_rlx);
return;
}
msgs += sent;
}
}

template <class Derived, class MessageTypeT, uint16_t MaxPacketSizeV>
Expand Down

0 comments on commit c22d781

Please sign in to comment.