-
-#ifdef HAVE_COREAUDIO
-
-int
-PluginManager::au_discover ()
-{
- int mNumUnits = 0;
- int numTypes = 2; // this magic number was retrieved from the apple AUHost example.
-
- ComponentDescription desc;
- desc.componentFlags = 0;
- desc.componentFlagsMask = 0;
- desc.componentSubType = 0;
- desc.componentManufacturer = 0;
-
- for (int i = 0; i < numTypes; ++i) {
- if (i == 1) {
- desc.componentType = kAudioUnitType_MusicEffect;
- } else {
- desc.componentType = kAudioUnitType_Effect;
- }
-
- int n = CountComponents (&desc);
-
- mNumUnits += n;
- }
- cout << "Number of AU plugins: " << mNumUnits << endl;
-
- ComponentDescription* mCompDescs = new ComponentDescription[mNumUnits];
-
- int n = 0;
- for (int i = 0; i < numTypes; ++i)
- {
- if (i == 1) {
- desc.componentType = kAudioUnitType_MusicEffect;
- } else {
- desc.componentType = kAudioUnitType_Effect;
- }
-
- Component comp = 0;
-
- comp = FindNextComponent (NULL, &desc);
- while (comp != NULL) {
- ComponentDescription temp;
- GetComponentInfo (comp, &temp, NULL, NULL, NULL);
- mCompDescs[n++] = temp;
- comp = FindNextComponent (comp, &desc);
- }
- }
-
- for (int i = 0; i < mNumUnits; ++i) {
-
- // the following large block is just for determining the name of the plugin.
- CFStringRef itemName = NULL;
- // Marc Poirier -style item name
- Component auComponent = FindNextComponent (0, &(mCompDescs[i]));
- if (auComponent != NULL) {
- ComponentDescription dummydesc;
- Handle nameHandle = NewHandle(sizeof(void*));
- if (nameHandle != NULL) {
- OSErr err = GetComponentInfo(auComponent, &dummydesc, nameHandle, NULL, NULL);
- if (err == noErr) {
- ConstStr255Param nameString = (ConstStr255Param) (*nameHandle);
- if (nameString != NULL) {
- itemName = CFStringCreateWithPascalString(kCFAllocatorDefault, nameString, CFStringGetSystemEncoding());
- }
- }
- DisposeHandle(nameHandle);
- }
- }
-
- // if Marc-style fails, do the original way
- if (itemName == NULL) {
- CFStringRef compTypeString = UTCreateStringForOSType(mCompDescs[i].componentType);
- CFStringRef compSubTypeString = UTCreateStringForOSType(mCompDescs[i].componentSubType);
- CFStringRef compManufacturerString = UTCreateStringForOSType(mCompDescs[i].componentManufacturer);
-
- itemName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ - %@ - %@"),
- compTypeString, compManufacturerString, compSubTypeString);
-
- if (compTypeString != NULL)
- CFRelease(compTypeString);
- if (compSubTypeString != NULL)
- CFRelease(compSubTypeString);
- if (compManufacturerString != NULL)
- CFRelease(compManufacturerString);
- }
- string realname = CFStringRefToStdString(itemName);
- cout << realname << endl;
- }
-
- delete[] mCompDescs;
-
- return 0;
-}
-
-#endif // HAVE_COREAUDIO
-