Re: Endpoint refcons are NULL
Re: Endpoint refcons are NULL
- Subject: Re: Endpoint refcons are NULL
- From: Doug Wyatt <email@hidden>
- Date: Mon, 7 Oct 2002 16:47:46 -0700
Oops! I missed this. Better late than never.
But the endpoint refcons are for the owning driver's use, not your
application's!
From MIDIDriver.h:
@function MIDIEndpointSetRefCons
@discussion Drivers need an efficient way to translate from a
MIDIEndpoint (source or
destination) to their own internal data structures corresponding to
that endpoint. This function provides a way for the driver to
assign its own refCons to endpoints.
These refCons are passed back to the driver in its Send() and
Flush()
methods.
RefCons are not persistent (i.e. they are not saved as part of a
MIDISetup). They need to be re-initialized in each call to
Start().
A typical use is to use one refCon to refer to a device, and a
second
to refer to a port on the device.
If on the other hand you are writing an application in conjunction with
a driver, then you might have valid reasons for your app to look at
them. But yes, by the time you get a notification that an object has
been removed, you can't get any more information about it than what is
being passed to the notify proc.
Doug
On Thursday, Sep 5, 2002, at 10:31 US/Pacific, Andy wrote:
Here's a code extract ...
elsewhere in the code endpoints are created and refcons are set using
MIDIEndpointSetRefCons()
also elsewhere I extract the endpoint refcons and use them
successfully, but when I receive this notification ...
void ClientNotifyProc(const MIDINotification * message, void *refCon)
{
switch ( message->messageID ) {
...
case kMIDIMsgObjectRemoved :
{
MIDIObjectAddRemoveNotification * marn =
(MIDIObjectAddRemoveNotification *) message;
if ( marn->childType == kMIDIObjectType_Source ) {
// child = source endpoint
// parent = port that owns endpoint
printf("MIDI SOURCE REMOVED FROM SETUP parent = X, child =
X\n", (int)marn->parent, (int)marn->child);
void * ref1 = 0;
void * ref2 = 0;
USBDevice * usbDevice;
OSStatus err =
MIDIEndpointGetRefCons((MIDIEndpointRef)marn->child, &ref1, &ref2);
printf("endpoint rc's 1 = X, 2 = X, err = %d\n",
(int)ref1, (int)ref2, (int)err);
}
}
break;
}
}
console output is this ...
MIDI SOURCE REMOVED FROM SETUP parent = 09810012, child = 09810013
endpoint rc's 1 = 00000000, 2 = 00000000, err = -50
Parent and Child values correspond to port and endpoint that were
created earlier on.
Why the -50 error, (param error ?)
Is it because the endpoints have already been destroyed and the
MIDIEndpointRef (marn->child) is no longer valid ?
_______________________________________________
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.
--
Doug Wyatt
work: email@hidden (CoreAudio)
personal: email@hidden
http://www.sonosphere.com
_______________________________________________
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.