Re: Blocked in MIDIClientCreate
Re: Blocked in MIDIClientCreate
- Subject: Re: Blocked in MIDIClientCreate
- From: Doug Wyatt <email@hidden>
- Date: Fri, 16 Dec 2005 15:14:37 -0800
On Dec 16, 2005, at 0:22, philippe wicker wrote:
On Dec 15, 2005, at 10:19 PM, Herbie Robinson wrote:
Hi Herbie, thanks for your answer:) More questions follow.....
At 6:50 PM +0100 12/14/05, philippe wicker wrote:
A good place to start to debug this would be to use Shark or
Sampler to get a trace of what MIDIServer is doing when it is
hung. We may or may not get clues about what's happening in the
USB stack from this; I am concerned that you may indeed need to
learn more about what's happening on the USB bus. But a sample
of the hung state would be a good place to start.
I've tried to use Sampler (recording IPC and Locking calls), but
I don't know how to attach the MIDIServer when it is relaunched.
If I attach it when I'm hung in MIDIClientCreate then nothing is
recorded (no activity of MIDIServer?).
Attach it with gdb and get a stack trace (of all the threads).
The difficulty is that the MIDIServer is launched when
MIDIClientCreate is called, so I cannot attach it because I don't
have a PID. Unless there is a trick I'm not aware of?
I debug the MIDIServer like this:
$ cd /System/Library/Frameworks/CoreMIDIServer.framework
$ gdb MIDIServer
$ run
Just fire this up before you launch *any* clients (i.e. that there
are no MIDIServers running already -- verify with "ps x").
It's usually pretty obvious at that point (but you may be close to
needing to rent that USB analyzer).
Yeah!! I've already asked my boss to rent such a device....
Another thing that might be useful is that the sample MIDI driver
is a USB class driver. You could build that in debug mode and use
it to help debug your hardware and firmware. I don't know how
close it is to that binaries that ship with the OS, but it's
almost certainly going to be helpful to debug with.
That's a good idea. I had a look at this sample and have some
questions about it:
- in the file SampleUSBMIDI.cpp there's some "things to customize":
-- the UUID: do I need to modify some of the bytes used to generate
the constant kFactoryUUID, and if so how?
Tiger ships with "uuidgen". Way back I wrote "mkuuid" which I think
you'd prefer. It's easily built from
/Developer/Examples/CoreMIDI/MIDI/SampleUSBDriver/mkuuid
-- What is the meaning of kTheInterfaceToUse ? Does it relate to
interface numbers in the USB descriptors?
Yes. It's passed to
USBInterface * USBDevice::FindInterface(
UInt8 desiredInterfaceNumber,
UInt8 desiredAlternateSetting)
If you haven't already, use USB Prober to find the interface number.
-- My device descriptors contain a single MIDIStreamingInterface
associated to one embedded jack IN and one embedded jack OUT.
Should I keep the value 2 (1 IN + 1 OUT) for kMyNumPorts constant?
No, you have one entity ("port" in that source) with a single
destination and single source. You want 1.
// make entity for each port, with 1 source, 1 destination
for (int port = 1; port <= kMyNumPorts; ++port) {
char portname[64];
if (kMyNumPorts > 1)
sprintf(portname, "Port %d", port);
else
CFStringGetCString(boxName, portname, sizeof(portname),
kCFStringEncodingMacRoman);
CFStringRef str = CFStringCreateWithCString(NULL, portname, 0);
MIDIDeviceAddEntity(dev, str, false, 1, 1, &ent);
CFRelease(str);
}
-- the 1 and 1 parameters to MIDIDeviceAddEntity are the numbers of
sources and destinations.
- The USB descriptors of my device are all class compliant (at
least I believe they are....). Will the sample MIDI driver be
loaded instead of the generic MIDI driver?
Yes. It's in /System/Library/Extensions/AppleMIDIUSBDriver.plugin.
Set it aside while you debug.
I only set kMyVendorID and kMyProductID to the values in my
descriptors and installed the sample driver in ~/Library/Audio/MIDI
Drivers.
Sorry for these numerous questions but I knew nearly nothing about
USB standard and drivers before starting this project. Starting
with a totally new audio and midi device is probably not the
simplest way to get familiar with all that stuff :)
There's a first time for everything : )
Cheers,
Doug
--
Doug Wyatt
Core Audio, Apple
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden