Re: Is the kMIDIPropertyUniqueID the same between reboots?
Re: Is the kMIDIPropertyUniqueID the same between reboots?
- Subject: Re: Is the kMIDIPropertyUniqueID the same between reboots?
- From: "X. J. Scott" <email@hidden>
- Date: Sat, 06 Mar 2004 21:31:15 -0500
on 3/6/04 8:49 PM, Cianflone, Chris wrote:
>
<<In rare cases, virtual ports might
>
possibly change if the program hosting them doesn't do it right,>>
>
And what is the "right" way to do this? I haven't seen anything about
>
generating a uniqueID for virtual sources and destinations. Did I miss this
>
somewhere?
After creating the virtual output port with for example
MIDIDestinationCreate(), CoreMIDI permits you to set the uniqueID with:
iStatus = MIDIObjectSetIntegerProperty
( aVirtualEndpointRef
, kMIDIPropertyUniqueID
, uniqueID
);
You should always use the same uniqueID for a given port, but since its
possible to change it, it's possible to be assigning different ones each
run, or not checking the iStatus return value to make sure it's noErr -- if
it's not, there may have been a conflict on the desired uniqueID and another
one has to be chosen and then restored with the next run.
It has been mentioned that it's not guaranteed that various properties are
defined for a given endpoint. Because of that, I always set the uniqueIDs on
my virtual ports, and also save them between runs. It's not required, but I
also always assign a kMIDIPropertyManufacturer and kMIDIPropertyModel string
property to my virtual ports as well, to show courtesy to other programs
that make use of that data.
--
Much more important than these issues in my opinion, is an understanding
that the structure of the ports can change at any moment and that MIDI
programs must be prepared to deal with routing configuration changes at any
time, with new ports coming and going at arbitrary times, especially such as
when other MIDI programs launch and create their own virtual ports. Keeping
track of everything by uniqueID makes it possible to deal with these changes
since the uniqueIDs will stay the same even thought the Endpoint references
might become invalid at any moment until the configuration is rebuilt.
- Jeff
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.