PaulStoffregen / USBHost_t36

USB Host Library for Teensy 3.6 and 4.0
167 stars 86 forks source link

fixed race condition in midi transmit #29

Closed essej closed 4 years ago

essej commented 5 years ago

Fixed race condition in midi transmit that could happen with heavy write traffic, in combination with reading. This would lock up the usb host device, when it happened. Disabling interrupts around access to the data queue in write_packed() matches what read() is already doing, so this seems like the correct solution.

gerotakke commented 4 years ago

Just wanted to chime in; I've used the unpatched library with a Teensy 3.6 and a 4.0 and ran into lost MIDI transmissions quite a bit, even when playing something like arpeggios regularly. It was even worse with an MPE controller where a lot more MIDI data is being sent. NoteOff and botched pitch bend messages were the main things I've witnessed. This patch fixed those issues; I've reapplied the changes to the current head and I haven't seen any problems even with MPE controllers after a couple of minutes of testing.

essej commented 4 years ago

Yes, I was testing with MPE controllers and discovered this bug immediately. Paul, if you are there, please merge this request for the good of others!

PaulStoffregen commented 4 years ago

Ok, merging now.

gerotakke commented 4 years ago

Thank you both very much!

essej commented 4 years ago

Great, thanks!