Strange MIDIPacket Sizes

While vigorously testing out my iOS app with a MIDI controller keyboard, I sometimes generate CoreMIDI input that is clearly garbage. Here is the code I use to iterate over the MIDIPacketList:

Code Block        
let numPackets = packetList.numPackets
os_log(.info, log: log, "processPackets - %d", numPackets)
var packet: MIDIPacket = packetList.packet
for index in 0..<numPackets {
os_log(.info, log: log, "packet %d - %d bytes", index, packet.length)
  // Filter out garbage (zero or really big sizes of 26624)
  if packet.length == 0 || packet.length > 30 {
  os_log(.error, log: log, "suspect packet size %d", packet.length)
    break
  }
  processPacket(packet, controller)
  packet = MIDIPacketNext(&packet).pointee
}

If I pound away on the keys and do a lot of pitch bends and mod wheel spins, I can sometimes get what appears to be garbage, with packets of either 0 or 22624 bytes (which is curiously 0x6800 hex). As above, I currently stop processing the MIDIPacketList when this happens, but that is clearly not a great solution. Anyone else encounter something like this?
Where is packetList from? Is this your ReadBlock? You get an UnsafePointer pointer there as a param. You can iterate over it via unsafeSequence()
I'm seeing a similar thing, but with MIDI data coming from RTP-MIDI network connections inbound. Anything that generates a reasonably significant amount of traffic will do it, and it seems fairly random. It appears to be a recent problem, as I've run the exact same code in the same situations a thousand times before but since one of the latest updates I've been seeing this... possibly a bug in CoreMIDI?

I should note, the odd sizes I'm seeing are exactly 0x7000 in length...

Do you know what the status bytes are for the first message in the incredibly long packets. These could be SystemExclusive messages which can be generated by the system automatically. Perhaps they are status dumps. The critical factor is the first twenty or so bytes in the packet.

Strange MIDIPacket Sizes
 
 
Q