Re: Use of the source refcon in MIDIProc callback
Re: Use of the source refcon in MIDIProc callback
- Subject: Re: Use of the source refcon in MIDIProc callback
- From: Kurt Revis <email@hidden>
- Date: Fri, 8 Nov 2002 17:25:06 -0800
On Friday, November 8, 2002, at 02:53 AM, Philippe Wicker wrote:
The MIDIProc callback receives a (void*) pointer as 3rd parameter
which is supposed to identify the source of the packet list. Does that
mean that packet lists send by different sources to the same endpoint
will never be merged in one packet list. In other words, can we safely
rely on the source refcon to, example given, filter midi events
according to the source?
I'm sorry, my original response was completely misleading and wrong.
Let me try again.
There are two different cases in which a MIDIReadProc can be called.
Let's look at them individually:
1. You have called MIDIInputPortCreate() and MIDIPortConnectSource().
The refCon that you passed to MIDIInputPortCreate() is given to your
MIDIReadProc as readProcRefCon.
The connRefCon that you passed to MIDIPortConnectSource() is given to
your MIDIReadProc as srcConnRefCon.
It is up to you to use srcConnRefCon to figure out what source endpoint
the input packet list is coming from.
Source endpoints are always managed by exactly one piece of code. For
a hardware device, it will be a driver running in the MIDIServer. For
a virtual source, it will be an application. This code calls
MIDIReceived() to put packets into the MIDI system; the MIDIServer is
responsible for passing them on to clients who are listening. There is
no possibility for any merging to happen.
(Theoretically, anyone could call MIDIReceived() on any endpoint they
like, even though it doesn't make any sense. I haven't tried it, but I
assume the MIDIServer will return an error if anyone but the creator of
the endpoint calls it.)
2. You have called MIDIDestinationCreate() to create a virtual
destination.
The refCon that you passed to MIDIDestinationCreate() is given to your
MIDIReadProc as readProcRefCon.
The srcConnRefCon that is given to your MIDIReadProc is meaningless;
there is no way to set it. You should just ignore it.
Multiple applications may be sending packets to your virtual
destination. The MIDIServer will merge them together. There is no way
to determine which application sent any particular packet.
I hope this made more sense!
--
Kurt Revis
email@hidden
_______________________________________________
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.