Re: No callback problem
Re: No callback problem
- Subject: Re: No callback problem
- From: Philippe Wicker <email@hidden>
- Date: Fri, 31 Jan 2003 21:11:57 +0100
On Friday, January 31, 2003, at 06:46 PM, Christian Martin wrote:
Hi,
I working on an application which send and receives sysex messages. I
am able to send sysex messages to the MIDI device since it is
responding accordingly. The MIDI device responds by sending other MIDI
messages which I can see coming in using a freeware called MIDI
Monitor. But the application never receive the messages or the
callback function does not. I am using OS X 10.2.3, Midisport USB 2x2,
the application is partly JAVA (GUI part) and partly C++ for handling
MIDI calls to CoreMIDI framework.
err = MIDIPortConnectSource(gInPort,
MIDIGetSource(gMHC.mhc_inDeviceID) /* integer between 0 and
GetNbrSources() */
(void*)0L );
The code looks correct.
Did you check if MIDIGetSource returns a valid (non null)
MIDIEndpointRef?
If it is valid, are you sure that "gMHC.mhc_inDeviceID" is initialized
with the actual index of the virtual source you want to connect to? You
may verify it by printing the name of the source endpoint returned by
MIDIGetSource (if you need it, I've posted a couple of week ago the
code to do that, search for PrintEndpointName).
static void ReceiveMessageProc( const MIDIPacketList *pktList,
void *unused,
void *srcConnRefCon )
{
unused;
volatile int nSensorNbr = 0;
mhc_mutex->lock();
mhc_mutex->unlock();
}
What is this mutex for? The MIDI thread in the context of which
ReceiveMessageProc is called is a **real time** thread and you should
not attempt to do any (possibly) blocking call while executing code in
the MIDI callback. At least, if you **need** to synchronize with
another thread (eg because you share complex structures that cannot be
atomically updated) , try to minimize the time when this mutex is
locked, and try to minimize the occurrence of locking by the other
thread. BTW, just to be sure, check that this mutex is unlocked when
you start.
Regards.
Philippe Wicker
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.