MIDI setup change notifications, overlapping
MIDI setup change notifications, overlapping
- Subject: MIDI setup change notifications, overlapping
- From: Kurt Revis <email@hidden>
- Date: Mon, 26 Nov 2001 11:06:10 -0800
I'm running into sort of a weird situation with the MIDI setup change
notification, and I'm wondering if it's a bug, or something I should be
prepared for.
I have one app which is running and has set a listener function for this
notification. I also have another app which creates a virtual source
(via MIDISourceCreate()) and then immediately sets its unique ID (via
MIDIObjectSetIntegerProperty()). It appears that both of these calls
cause a MIDINotification to happen.
The problem is this: My first app can get the second MIDINotification
while it is in the middle of handling the first one. It seems that any
MIDI call (such as MIDIGetNumberOfSources()) causes the run loop to run,
and the notification to be delivered immediately.
To clarify, here's the sequence of events:
1) App 1: calls MIDISourceCreate()
2) App 2: runs its main run loop, and its MIDINotifyProc is called. It
starts thinking about what to do.
3) App 1: calls MIDIObjectSetIntegerProperty(endpoint,
kMIDIPropertyUniqueID, uniqueID)
4) App 2: calls MIDIGetNumberOfSources() to find out what sources exist
now.
5) App 2: MIDIGetNumberOfSources() runs the run loop again, and sees
that it should send a notification
6) App 2: The MIDINotifyProc gets called again.
Needless to say, it seems like needless pain to force everyone to make
their MIDINotifyProc reentrant. Is it expected that I handle this case,
or is this a bug?
(I'm not really an expert on run loops, but it also seems bizarre for
the MIDI functions to run my app's main run loop--I can't think of any
other functions that do that. Correct me if I'm wrong here, but
couldn't CoreMIDI have its own run loop that it uses internally?)
--
Kurt Revis
email@hidden