microsoft / MIDI

Windows MIDI Services
MIT License
289 stars 23 forks source link

[BUG] Multiple UMP Messages in single USB Packet #165

Open AmeNote-Michael opened 7 months ago

AmeNote-Michael commented 7 months ago

Applies To USB Driver or Service

Describe the bug Transmission of multiple UMP messages in a single USB Packet is not being properly handled by system. Messages are dropped.

To Reproduce Using a USB MIDI 2.0 device like ProtoZOA, connect and send in single USB packet a set of UMP messages like: 40 91 23 45 67 89 00 00 40 91 23 45 67 89 00 01 40 91 23 45 67 89 00 02 40 91 23 45 67 89 00 03

Using midi.exe console application, observe that not all messages received through system by Windows. midi endpoint monitor --verbose

Note this issue was reported originally by AMEI (Yamaha: Daisuke Miura). Supplied by AMEI, attached .uf2 file loads onto ProtoZOA UUT to reproduce issue.

Expected behavior All 4 messages sent should be observed in the console application.

Screenshots

Desktop (please complete the following information):

AmeNote-Michael commented 6 months ago

@dmiura testing with @Psychlist1972 latest developer release and driver - Developer Preview 3 I have not been able to reproduce issue. It is possible that something in queuing or displaying causes the issue.

Even with latest preview, the buffer falls behind on midi endpoint monitor --verbose such that after unplugging the test device from USB, it took some time before the display scrolling stops.

Can you please try again and confirm issue with latest developer preview.

Psychlist1972 commented 6 months ago

@AmeNote-Michael

Multiple UMP messages in a single transfer to or from the service are not supported, especially not at the API level. Did Gary do something special with the USB interface to pull apart the messages and support this scenario for the USB driver?

There are a number of checks in various places to ensure we're dealing with a single message at a time.

Psychlist1972 commented 5 months ago

@AmeNote-Michael also getting reports related to this from others. I've asked folks to comment here.

m-komo commented 5 months ago

@AmeNote-Michael I've run the following command on the ProtoZOA.

midi.exe send-message 0x41234567 0x00000000 --count 10000 --pause 0 --debug-auto-increment

Since there is no message interval, the MIDI Service finishes sending messages instantly. However, it seems that the driver only sends one UMP per transaction. It is expected that the driver sends multiple UMPs per transaction (URB) to get better performance if there are several UMPs in the buffer sent from the service.

ProtoZOA-send_message_zero_interval

AmeNote-Michael commented 5 months ago

@m-komo I pass the UMP data to the USB device as I receive them from the service. I will discuss with team how we can look to group messages better.

AmeNote-Michael commented 5 months ago

@dmiura I looked closely at code and it appears that the driver is properly capturing the 4 packets and passing up to service. Will need to investigate further with rest of team.

AmeNote-Michael commented 5 months ago

@dmiura I investigated further on weekend. I believe I have figured out mechanism on why USB Out is sending only one UMP per USB packet. Essentially I have no policy on number USB packets queued to send, as long as USB stack accepts a packet to send, I create and send it.

With no limit, driver could submit hundreds if not thousands of single UMP packet messages to USB to send to device.

Driver will be updated to limit the number of USB send packets to device which should force to group UMP messages.

m-komo commented 4 months ago

@AmeNote-Michael Any update on the DP5 driver? It seems that the driver still sends one UMP per transaction.