void CAComponent::SetCompNames () const { if (!mCompName) { CFStringRef compName; OSStatus result = AudioComponentCopyName (Comp(), &compName); if (result) return; const_cast<CAComponent*>(this)->mCompName = compName; if (compName) { CFArrayRef splitStrArray = CFStringCreateArrayBySeparatingStrings(NULL, compName, CFSTR(":")); // we need to retain these values so the strings are not lost when the array is released const_cast<CAComponent*>(this)->mManuName = (CFStringRef)CFArrayGetValueAtIndex(splitStrArray, 0); CFRetain(this->mManuName); if (CFArrayGetCount(splitStrArray) > 1) { CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(splitStrArray, 1); CFMutableStringRef mstr = CFStringCreateMutableCopy (NULL, CFStringGetLength(str), str); // this needs to trim out white space: CFStringTrimWhitespace (mstr); const_cast<CAComponent*>(this)->mAUName = mstr; } else const_cast<CAComponent*>(this)->mAUName = NULL; CFRelease(splitStrArray); } } }
static QStringList enumerateAudioUnits(OSType componentType) { QStringList plugins; AudioComponent component = NULL; AudioComponentDescription description; memset(&description, 0, sizeof(description)); description.componentType = componentType; while ((component = AudioComponentFindNext(component, &description))) { CFStringRef cfname; if (AudioComponentCopyName(component, &cfname) != 0) { continue; } plugins.append(cfstringToQString(cfname)); CFRelease(cfname); } return plugins; }
static AudioComponent findAudioUnit(const QString &componentName) { AudioComponent component = NULL; AudioComponentDescription description; memset(&description, 0, sizeof(description)); while ((component = AudioComponentFindNext(component, &description))) { CFStringRef cfname; if (AudioComponentCopyName(component, &cfname) != 0) { continue; } QString name(cfstringToQString(cfname)); CFRelease(cfname); if (name == componentName) { return component; } } return NULL; }