Re: Multiple instances of an Audio Device
Re: Multiple instances of an Audio Device
- Subject: Re: Multiple instances of an Audio Device
- From: Heiko Panther <email@hidden>
- Date: Fri, 27 Sep 2002 15:38:37 +0200
Stephan wrote:
We had the very same problem. There's a bug in IOAudioEngine::getGlobalUniqueID(
). It fails to return different strings for different instances of the same
PCI hardware. Just override getGlobalUniqueID in your AudioEngine subclass
(using a different string for each hardware instance) and you'll see both.
Actually, it's not getGlobalUniqueID that fails. The GUID it makes is a string composed of your engine class name, the location, and a local ID. The local ID is set to the count of IOAudioEngines your IOAudioDevice has created yet. The location is not set, because it is specific to the kind of Audio Device you have. For a USB device, the USB device location could go there, for a PCI device, the PCI slot number would be appropriate. You could also put the serial number of your device there.
Here's some code that will look up the slot name in the IORegistry and set the location accordingly. It should go into your initHardware() function of you IOAudioEngine subclass. With this, you don't need to override getGlobalUniqueID().
IORegistryEntry *regent=getParentEntry(gIOServicePlane);
if(!regent)
IOLog("couldn't get parent IOServicePlane %p\n", gIOServicePlane);
else
{
regent=regent->getParentEntry(gIOServicePlane);
if(!regent)
IOLog("couldn't get grandparent\n");
else
{
OSObject *prop=regent->getProperty("AAPL,slot-name");
if(!prop)
IOLog("could not get property\n");
else
{
OSData *slotname=OSDynamicCast(OSData, prop);
if(!slotname)
IOLog("cast unsuccessful\n");
else
{
#define str_max_size 15
char str[str_max_size+1];
UInt32 len=(slotname->getLength() < str_max_size ? slotname->getLength() : str_max_size);
memcpy(str, slotname->getBytesNoCopy(), len);
str[len]=0;
setLocation(str);
}
}
}
}
Greetings
Heiko Panther
_______________________________________________
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.