Calling "performAsynchronousMessageExchangeWithBlock:" from CoreMIDI thread?
I was wondering, is it safe to call "performAsynchronousMessageExchangeWithBlock:" from threads other than the main thread? If not, any other ideas for safely getting data from the CoreMIDI realtime thread to the audio thread?
Any input would be greatly appreciated :]
Threads other than the main thread are fine, but not from a realtime thread as it can cause priority inversion. As I understand it, the Core MIDI thread is indeed realtime, so I wouldn't recommend this. It may be better to use a circular buffer to shuttle data around, and polling or similar. With that said, I don't know for sure that the Core MIDI thread needs to be treated with the same degree of care as the audio thread.
Hey Michael, thanks for the reply. I've decided to use it at the moment, but I'm honestly unsure what would happen if there was priority inversion situation on the CoreMIDI thread.
Any idea what would happen in the worst case scenario? If it's just messages coming in a bit later than intended, do you think using timestamps and sending midi messages ahead of time would be enough to counter this problem?
Actually, I pretty much share your uncertainty, there - it probably depends on the MIDI stuff in question, but as you say, the existence of timestamps would pretty much negate most problems!